Skip to content

Instantly share code, notes, and snippets.


Anton Tayanovskyy t0yv0

View GitHub Profile
t0yv0 / main.go
Created Mar 18, 2021
Cost of embedding Go structs with methods
View Setup.fsx
# Setup.fsx
Adds registry keys for proper F# Web project support.
**Problem**: pure-F# Web projects do not work well in Visual Studio by default,
in particular adding a new item to the project is not possible.
**Solution**: This will hopefully be addressed in future VS versions.
t0yv0 / Clone.fs
Created Jun 3, 2014
Generic clone recipe with Infers.
View Clone.fs
module Main
open Infers
open Infers.Rep
type SimpleRecord = { Name: string; Age: int }
type LotsOfRecords = { People: SimpleRecord [] }
type Cloneable<'T> =
| C of ('T -> 'T)
View Protocol.fs
Towards verifying message-passing protocols.
Protocol typically involves two parties, let us call Client and Server,
a number of states and state transitions involving passing of messages.
Client has agency - non-deterministic process in process calculi.
Server is deterministic, but it should handle all possible clients.
Ideally, we would take a DSL for the protocol, and spit out F# code that
View FSharpIdea.fs
module M =
[<PrivateRecordConstructor>] // how about F# had something like this?
type Config =
A: string
B: string
// ...
t0yv0 / ParWithLog.fs
Created Feb 6, 2014
Par monad extended with deterministic available-as-soon-as-possible logging.
View ParWithLog.fs
namespace Examples
type Future<'T>
module Future =
View CSP.fs
type Proc<'T> =
| P of ('T -> option<Proc<'T>>)
exception Bleep
let def f =
P (fun x -> try Some (f x) with Bleep | MatchFailureException _ -> None)
let rec ( <||> ) (P a) (P b) =
let f x =
t0yv0 / Kombinators.v
Created Oct 5, 2013
Kombinators for scaling simple trait and/or combinators to n-way product/sum combinators.
View Kombinators.v
Inductive choice a b :=
| C1 : a -> choice a b
| C2 : b -> choice a b.
Notation " a ++ b " := (choice a b).
Module Type TRAIT.
Parameter t : Type -> Type.
Parameter and : forall {a b}, t a -> t b -> t (a * b).
Parameter or : forall {a b}, t a -> t b -> t (a ++ b).
View FsPickler.Records.fs
type Person =
Address : string
Age : int
Name : string
let makePerson name age address =
Address = address
View GenericsExperiment.fs
module GenericsExperiment
/// Generic property interface. Since F# lacks higher kinds,
/// we cannot write code parametric in `P`, so instead write code with casts
/// in terms of an open type `P<'T>`.
type P<'T> =
/// Implements derivation rules for a certain generic property.