View universal_construction.fs
open Marvel
open System.Collections.Concurrent
open System.Collections.Generic
type Pid = int
type Op = {
op : string
sn : SN
}
View binary-consensus-task.md
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)
View unique-id-task-spec.md
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)
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
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>
View fad.fs
/// A value together with its derivative.
[<NoComparison>]
type D<'a> = D of 'a * 'a
module D =
[<GeneralizableValue>]
let inline GenericTwo () =
LanguagePrimitives.GenericOne + LanguagePrimitives.GenericOne
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.
[<CompilationRepresentation(CompilationRepresentationFlags.ModuleSuffix)>]
module DVar =
View Tcp.fs
/// Operations on Berkley sockets.
[<CompilationRepresentation(CompilationRepresentationFlags.ModuleSuffix)>]
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 ()
View AsyncEvent.fs
/// An async observer.
type AsyncObserver<'a> = 'a option -> Async<unit>
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> =
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