Skip to content

Instantly share code, notes, and snippets.

View t0yv0's full-sized avatar

Anton Tayanovskyy t0yv0

View GitHub Profile
@t0yv0
t0yv0 / ParWithLog.fs
Created February 6, 2014 15:16
Par monad extended with deterministic available-as-soon-as-possible logging.
#if INTERACTIVE
#else
namespace Examples
#endif
(*
[<Sealed>]
type Future<'T>
module Future =
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
t0yv0 / Kombinators.v
Created October 5, 2013 00:02
Kombinators for scaling simple trait and/or combinators to n-way product/sum combinators.
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).
type Person =
{
Address : string
Age : int
Name : string
}
let makePerson name age address =
{
Address = address
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> =
interface
end
/// Implements derivation rules for a certain generic property.
This file has been truncated, but you can view the full file.
Mono log profiler data
Profiler version: 0.4
Data version: 4
Mean timer overhead: 5844 nanoseconds
Program startup: Tue Apr 2 17:00:45 2013
Program ID: 3508
Server listening on: 55256
JIT summary
// Example 1: `any` allows unsafe casts
var x : any = 1;
x();
// Example 2: subtyping on functions allows unsafe casts
interface I1 { x: number; }
interface I2 { x: number; y: number; }
function f(g: (x: I1) => void) { g({x: 1}); }
@t0yv0
t0yv0 / Opt.v
Created March 23, 2013 15:35
A simple example of how to use Coq as a programming language - how to compute more efficient programs out of declarative programs, and then extract the efficient programs to ML. This facility is very obvious to serious users of Coq, but it took me a while as a beginner to realize this is practical and how can it be done. Compilers like Haskell d…
Require Import String.
Definition Parser (a : Type) :=
string -> option (a * string).
Definition Return {a} (x: a) : Parser a :=
fun s => Some (x, s).
Definition Bind {a b} (x: Parser a) (f: a -> Parser b) : Parser b :=
fun s =>
@t0yv0
t0yv0 / PKGBUILD
Created March 23, 2013 13:44
Corrections to the fsharp-git Arch Linux PKGBUILD to make it work (downgrading to a previous tag of F# open source repo)
# Maintainer: Joris Putcuyps <Joris.Putcuyps at gmail dot com>
pkgname=fsharp-git
pkgver=20130323
pkgrel=1
pkgdesc="An ML based functional language integrated with the .NET platform."
arch=('any')
url="http://msdn.microsoft.com/en-us/fsharp"
license=('APACHE')
groups=()
depends=('mono>=2.10.2')
// Capture: http://docs.phonegap.com/en/2.5.0/cordova_media_capture_capture.md.html
module Capture {
interface ConfigurationData {
type: string;
height: number;
width: number;
}