Instantly share code, notes, and snippets.

# Lev Gorodinskieulerfx

• Sort options
Last active Sep 10, 2017
I Δ(I) I Δ(I)
(0,⊥) (0,⊥) (1,⊥) (1,⊥)
(⊥,0) (⊥,0) (⊥,1) (⊥,1)
(0,0) (0,0) (1,1) (1,1)
(0,1) (0,0), (1,1) (1,0) (0,0), (1,1)
Last active Aug 12, 2017
I Δ(I)
(0,⊥,⊥) (0,⊥,⊥), (1,⊥,⊥), (2,⊥,⊥)
(⊥,0,⊥) (⊥,0,⊥), (⊥,1,⊥), (⊥,2,⊥)
(⊥,⊥,0) (⊥,⊥,0), (⊥,⊥,1), (⊥,⊥,2)
(0,0,⊥) (0,1,⊥), (1,0,⊥), (0,2,⊥), (2,0,⊥), (2,1,⊥), (1,2,⊥)
(0,⊥,0) (0,⊥,1), (1,⊥,0), (0,⊥,2), (2,⊥,0), (2,⊥,1), (1,⊥,2)
(⊥,0,0) (⊥,0,1), (⊥,1,0), (⊥,0,2), (⊥,2,0), (⊥,2,1), (⊥,1,2)
(0,0,0) (0,1,2), (0,2,1), (1,0,2), (1,2,0), (2,0,1), (2,1,0)
Created Jun 21, 2017
F# applicative CLI option parser
View opt-parse.fs
 let readInt (s:string) = match System.Int32.TryParse s with | true,i -> Some i | _ -> None type Opt<'a> = Opt of name:string * defaultValue:'a option * read:(string -> 'a option) with static member Name<'a> (Opt(n,_,_) : Opt<'a>) = n static member Read<'a> (Opt(_,_,r) : Opt<'a>) = r static member Default<'a> (Opt(_,d,_) : Opt<'a>) = d
Created Nov 9, 2016
Probabilistic functional programming F#
View pfp.fs
 /// A probability is a number between 0 and 1 inclusive. type Prob = float /// A distribution is a sequence of outcome-probability pairs such that the /// probabilities sum to 1. type Dist<'a> = D of seq<'a * Prob> /// A spread takes a sequence of elements and assigns probabilities. type Spread<'a> = 'a list -> Dist<'a>
Last active May 14, 2016
F# automatic differentiation
 /// A value together with its derivative. [] type D<'a> = D of 'a * 'a module D = [] let inline GenericTwo () = LanguagePrimitives.GenericOne + LanguagePrimitives.GenericOne
Created May 14, 2016
DVar - dependent/dynamic variables
View DVar.fs
 open System open System.Threading /// A dependant variable. type DVar<'a> = private { cell : 'a ref ; event : Event<'a> } /// Operations on dependant variables. [] module DVar =
Created May 14, 2016
F# sockets, framing, sessions
View Tcp.fs
 /// Operations on Berkley sockets. [] module Socket = /// Executes an async socket operation. let exec (alloc:unit -> SocketAsyncEventArgs, free:SocketAsyncEventArgs -> unit) (config:SocketAsyncEventArgs -> unit) (op:SocketAsyncEventArgs -> bool) (map:SocketAsyncEventArgs -> 'a) = Async.FromContinuations <| fun (ok, error, _) -> let args = alloc ()
Created Feb 6, 2015
AsyncEvent (an F# async based Rx)
View AsyncEvent.fs
 /// An async observer. type AsyncObserver<'a> = 'a option -> Async module AsyncObserver = let inline post a (obs:AsyncObserver<'a>) = obs (Some a) let inline stop (obs:AsyncObserver<'a>) = obs None let contramap (f:'b -> 'a) (o:AsyncObserver<'a>) : AsyncObserver<'b> =
Last active Aug 29, 2015
F# HList unsafe fold
View HListFoldish.fs
 // for http://www.fssnip.net/d2 type Fold<'b> = Fold of f:('b -> obj -> 'b) * z:'b with static member inline (\$) (Fold(_,z), HNil) = z static member inline (\$) (Fold(f,z), HCons(a,xs)) = f (Fold(f,z) |*| xs) a // use
Created Dec 10, 2014
An F# Hopac input-output channel to ensure that inputs passed to a function are processed one at a time in fifo order
View HopacIoCh.fs
 open Hopac open Hopac.Infixes open Hopac.Job.Infixes open Hopac.Extensions type IoCh<'i, 'o> = Ch<'i * IVar<'o>> module IoCh = let create (f:'i -> Job<'o>) : Job> =
You can’t perform that action at this time.