Skip to content

Instantly share code, notes, and snippets.

Lev Gorodinski eulerfx

Block or report user

Report or block eulerfx

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
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)
@eulerfx
eulerfx / unique-id-task-spec.md
Last active Aug 12, 2017
Unique-id Task Specification
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)
@eulerfx
eulerfx / opt-parse.fs
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
@eulerfx
eulerfx / pfp.fs
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>
@eulerfx
eulerfx / fad.fs
Last active May 14, 2016
F# automatic differentiation
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
@eulerfx
eulerfx / DVar.fs
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.
[<CompilationRepresentation(CompilationRepresentationFlags.ModuleSuffix)>]
module DVar =
@eulerfx
eulerfx / Tcp.fs
Created May 14, 2016
F# sockets, framing, sessions
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 ()
@eulerfx
eulerfx / AsyncEvent.fs
Created Feb 6, 2015
AsyncEvent (an F# async based Rx)
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> =
@eulerfx
eulerfx / HListFoldish.fs
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
@eulerfx
eulerfx / HopacIoCh.fs
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<IoCh<'i, 'o>> =
You can’t perform that action at this time.