This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Client = | |
let connectionString = Environment.GetEnvironmentVariable("CONN") | |
let session = new Session(connectionString) | |
let doA (a : A) = session.Send a | |
let doB (b : B) = session.Send b | |
type Client(connectionString : string) = |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
open System | |
open System.Runtime.CompilerServices | |
type SymbolicException = | |
{ | |
Source : Exception | |
Stacktrace : string list | |
} | |
module SymbolicException = |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"Success": { | |
"_flags": "subtype", | |
"subtype": { | |
"Case": "GenericTypeInstance", | |
"GenericDefinition": { | |
"Case": "NamedType", | |
"Name": "MBrace.Core.Builders+Bind@331-1", | |
"Assembly": { | |
"Name": "MBrace.Core", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
open System | |
open System.Reflection | |
open Microsoft.FSharp.Quotations | |
open Microsoft.FSharp.Quotations.Patterns | |
open Microsoft.FSharp.Quotations.DerivedPatterns | |
type MethodInfo with | |
/// Gets the underlying method definition | |
/// including the supplied declaring type and method type arguments |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Test = | |
static member F<'T>(t : 'T option) = () | |
static member F<'T>(e : 'T -> 'T) = () | |
type Foo = { A : int } | |
type Bar = { A : int } | |
Test.F(fun (r:Foo) -> { r with A = 32 }) // type checks | |
Test.F(fun (r:Bar) -> { r with A = 32 }) // type checks | |
Test.F<Foo>(fun r -> { r with A = 32 }) // type error |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Cont<'T> = ('T -> unit) -> (exn -> unit) -> unit | |
let ret t = fun sc _ -> sc t | |
let (>>=) f g = | |
fun sc ec -> | |
let sc' (t : 'T) = | |
match (try Choice1Of2 (g t) with e -> Choice2Of2 e) with | |
| Choice1Of2 g -> g sc ec | |
| Choice2Of2 e -> ec e |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let run x = Async.RunSynchronously x | |
let runParallel (workflow : Async<'T>) = | |
[| for i in 1 .. 100 -> workflow |] | |
|> Async.Parallel | |
|> run | |
let a = async { return 42 } | |
let b = async { return run (async { return 42 })} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// current type abbreviations in F# | |
type A = Guid | |
type B = Guid | |
let foo (x : A) = x.ToString() | |
let b = B.NewGuid() | |
foo(b) // type checks | |
// proposed newtype abbreviations | |
newtype A = Guid |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let inline map (alg : ^Alg) (f : ^t -> ^s) (ts : ^ts) : ^ss = | |
(^Alg : (member Map : (^t -> ^s) * ^ts -> ^ss) (alg, f, ts)) | |
let inline filter (alg : ^Alg) (f : ^t -> bool) (ts : ^ts) : ^ts = | |
(^Alg : (member Filter : (^t -> bool) * ^ts -> ^ts) (alg, f, ts)) | |
let inline reduce (alg : ^Alg) (f : ^t -> ^t -> ^t) (ts : ^ts) : ^t = | |
(^Alg : (member Reduce : (^t -> ^t -> ^t) * ^ts -> ^t) (alg, f, ts)) | |
// type signature is unreadable, machine consumable only |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Stream<'T> = ('T -> unit) -> unit | |
module Stream = | |
let inline groupWhile (pred : 'T -> bool) (source : Stream<'T>) : Stream<'T []> = | |
fun k -> | |
let ra = new ResizeArray<'T> () | |
let iter (t : 'T) = | |
if not <| pred t then | |
k <| ra.ToArray() | |
ra.Clear() |