Skip to content

Instantly share code, notes, and snippets.

module XmlCE
open IntelliFactory.WebSharper
// I don't want to open IF.WS.Html here, because I'm defining my own HTML combinators
type IPagelet = IntelliFactory.WebSharper.Html.IPagelet
module E = IntelliFactory.WebSharper.Html.Events
/// The type of XML attributes.
/// I added a couple DOM events to show that we can have more
/// than just key/value attributes.
open IntelliFactory.WebSharper
open Microsoft.FSharp
let hasRefDef (t: System.Type) =
match t.GetMethods() |> Seq.find (fun m -> m.Name = "get_Body") with
| Quotations.DerivedPatterns.MethodWithReflectedDefinition d -> true
| _ -> false
type Foo() =
inherit Web.Control()
let getUser =
<@ fun userId ->
query { for u in db.User do
where (u.Id = userId)
select u } @>
let q =
query { for t in db.Topic do
for user in (%getUser) t.CreatedBy do
#r "Microsoft.Build"
#r "Microsoft.Build.Framework"
#r "Microsoft.Build.Engine"
open System
open Microsoft.Build.BuildEngine
open Microsoft.Build.Framework
let engine = new Engine()
engine.RegisterLogger(new ConsoleLogger())
Debugger entered--Lisp error: (void-variable setup-hook)
ergoemacs-user--325f9eb3b180efe44bc125f10df1a8be()
read-from-minibuffer("Customize variable: " nil (keymap (7 . minibuffer-keyboard-quit) (10 . minibuffer-complete-and-exit) (13 . minibuffer-complete-and-exit) keymap (7 . minibuffer-keyboard-quit) (menu-bar keymap (minibuf "Minibuf" keymap (tab menu-item "Complete" minibuffer-complete :help "Complete as far as possible") (space menu-item "Complete Word" minibuffer-complete-word :help "Complete at most one word") (63 menu-item "List Completions" minibuffer-completion-help :help "Display all possible completions") "Minibuf")) (27 keymap (118 . switch-to-completions)) (prior . switch-to-completions) (63 . minibuffer-completion-help) (32 . minibuffer-complete-word) (9 . minibuffer-complete) keymap (menu-bar keymap (minibuf "Minibuf" keymap (previous menu-item "Previous History Item" previous-history-element :help "Put previous minibuffer history element in the minibuffer") (next menu-item "Next History
let mutable result = Unchecked.defaultof< ^a>
let success = Int32.TryParse("12", &result)
// can be written as:
let success, result = Int32.TryParse("12")
@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
@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 / 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 / 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