Skip to content

Instantly share code, notes, and snippets.

View kayceesrk's full-sized avatar

KC Sivaramakrishnan kayceesrk

View GitHub Profile
@kayceesrk
kayceesrk / serialize_test.sml
Created April 1, 2015 17:38
MLton serialization example
fun serialize1 () =
let
val v = "ABCD"
val ser_v = MLton.serialize v
val v' = MLton.deserialize ser_v
in
print (v' ^ "\n")
end
datatype List = Nil | Cons of (int * List)
@kayceesrk
kayceesrk / stack-overflow.ml
Created June 3, 2015 15:35
Stack overflow
effect E1 : unit
effect E2 : unit
let foo f =
try f () with effect E1 k -> continue k ()
let bar () =
for i = 0 to 1000000 do
Printf.printf "bar %d\n%!" i;
perform E1
@kayceesrk
kayceesrk / spawn.ml
Created June 9, 2015 21:09
spawn continue
effect Wut : unit
effect Wat : unit
let rec foo n =
Printf.printf "[%d] foo\n%!" @@ Domain.self ();
Unix.sleep 1;
if n == 0 then
(perform Wat; foo 1)
else
(perform Wut; foo 1)
@kayceesrk
kayceesrk / test_deadlock.ml
Created August 18, 2015 10:24
Trigger read fault deadlock.
let r1 : int list ref = ref [1024]
let r2 : int list ref = ref [1024]
let rec foo lr fr = function
| 0 -> foo lr fr 1024
| i ->
let v = Random.int i in
lr := [v];
foo lr fr @@ List.hd(!fr)
@kayceesrk
kayceesrk / rand.rkt
Created January 19, 2016 13:01
Redex amb
#lang racket
(require redex)
(define-language L
(e (e e)
(λ (x t) e)
x
(amb e ...)
number
(+ e ...)
module type Arrow =
sig
type ('a,'b) t
val arr : ('a -> 'b) -> ('a, 'b) t
val (>>>) : ('a,'b) t -> ('b,'c) t -> ('a,'c) t
val first : ('a,'b) t -> ('a * 'c, 'b * 'c) t
end
module type Arrow_choice =
sig
module type Arrow =
sig
type ('a,'b) t
val arr : ('a -> 'b) -> ('a, 'b) t
val (>>>) : ('a,'b) t -> ('b,'c) t -> ('a,'c) t
val first : ('a,'b) t -> ('a * 'c, 'b * 'c) t
end
module type Arrow_choice =
sig
module type Arrow =
sig
type ('a,'b) t
val arr : ('a -> 'b) -> ('a, 'b) t
val (>>>) : ('a,'b) t -> ('b,'c) t -> ('a,'c) t
val first : ('a,'b) t -> ('a * 'c, 'b * 'c) t
end
module type Arrow_choice =
sig
module type Applicative = sig
type 'a t
val pure : 'a -> 'a t
val (<*>) : ('a -> 'b) t -> 'a t -> 'b t
end
module type Promise = sig
include Applicative
val fork : (unit -> 'a) -> 'a t
val get : 'a t -> ('a, exn) result
@kayceesrk
kayceesrk / move.diff
Created April 10, 2016 10:58
move.diff
diff --git a/boot/ocamlc b/boot/ocamlc
index 6c7ba14..c063309 100755
Binary files a/boot/ocamlc and b/boot/ocamlc differ
diff --git a/boot/ocamldep b/boot/ocamldep
index 29ad003..26935c5 100755
Binary files a/boot/ocamldep and b/boot/ocamldep differ
diff --git a/boot/ocamllex b/boot/ocamllex
index 2e40046..5da3c7e 100755
Binary files a/boot/ocamllex and b/boot/ocamllex differ
diff --git a/byterun/addrmap.c b/byterun/addrmap.c