(* raw continuation *)
type ('a,'b) stack
perform : 'a eff -> 'a
resume : ('a,'b) stack -> ('c -> 'a) -> 'c -> 'b
delegate : 'a eff -> ('a,'b) stack -> 'b
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#lang racket | |
(require redex) | |
(define-language L | |
(e (e e) | |
(λ (x t) e) | |
x | |
(amb e ...) | |
number | |
(+ e ...) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
OlderNewer