Skip to content

Instantly share code, notes, and snippets.

namespace Sample
open WebSharper
open WebSharper.JavaScript
open WebSharper.UI
open WebSharper.UI.Client
open WebSharper.UI.Html
open WebSharper.Highcharts
open WebSharper.JQuery
open WebSharper
open WebSharper.JavaScript
open WebSharper.UI.Next
open WebSharper.UI.Next.Client
open WebSharper.UI.Next.Html
open WebSharper.UI.Next.Notation
[<JavaScript>]
module Client =
@Tarmil
Tarmil / Setup.fsx
Created June 13, 2017 07:46
F# Web project on VS2017
(*
# Setup.fsx
Adds registry keys for proper F# Web project support.
**Problem**: pure-F# Web projects do not work well in Visual Studio by default,
in particular adding a new item to the project is not possible.
**Solution**: This will hopefully be addressed in future VS versions.
@Tarmil
Tarmil / Main.fs
Last active May 1, 2017 12:20 — forked from Youenn-Bouglouan/Main.fs
Websharper - issue with POST expecting a JSON body
// Issue decribed here: http://websharper.com/question/82758/post-endpoint-with-a-json-body-cannot-be-reached
namespace HelloWebSharper
open WebSharper.Html.Server
open WebSharper
open WebSharper.Sitelets
module Site =
module MergeSort
let sortBy cmp xs =
let rec sequences xs =
match xs with
| a :: b :: xs ->
if cmp a b > 0
then descending b [a] xs
else ascending b (fun ys -> a :: ys) xs
| xs -> [xs]
@Tarmil
Tarmil / TestLensMacro.fs
Created May 1, 2016 07:12
A WebSharper macro to reduce boilerplate for lenses on records
namespace TestLensMacro
open WebSharper
open WebSharper.JavaScript
open WebSharper.JQuery
open WebSharper.UI.Next
open WebSharper.UI.Next.Client
module Extensions =
module M = WebSharper.Core.Macros
@Tarmil
Tarmil / Counter.fs
Created March 13, 2016 11:52
Port of the first example from https://github.com/evancz/elm-architecture-tutorial to WebSharper; lens-based version
namespace Example1
open WebSharper
open WebSharper.UI.Next
open WebSharper.UI.Next.Html
open WebSharper.UI.Next.Client
[<JavaScript>]
module Counter =
@Tarmil
Tarmil / Counter.fs
Last active October 6, 2016 22:16
Port of the first example from https://github.com/evancz/elm-architecture-tutorial to WebSharper
namespace Example1
open WebSharper
open WebSharper.UI.Next
open WebSharper.UI.Next.Html
open WebSharper.UI.Next.Client
[<JavaScript>]
module Counter =
@Tarmil
Tarmil / gist:98cb7a0fb78e22aa4fde
Last active November 28, 2016 14:02
Compile a quotation with WebSharper.Compiler
// NuGet reference: WebSharper.Compiler
open WebSharper
type AR = IntelliFactory.Core.AssemblyResolution.AssemblyResolver
module FE = WebSharper.Compiler.FrontEnd
let compile (expr: Microsoft.FSharp.Quotations.Expr) : string option =
let loader = FE.Loader.Create (AR.Create()) (eprintfn "%O")
let options =
{ FE.Options.Default with
let mutable result = Unchecked.defaultof< ^a>
let success = Int32.TryParse("12", &result)
// can be written as:
let success, result = Int32.TryParse("12")