Created
May 9, 2019 10:57
-
-
Save rizo/23fbdd072a5eaad0783778c516989c29 to your computer and use it in GitHub Desktop.
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 Continuation : sig | |
type ('a, 'r) t = ('a -> 'r) -> 'r | |
val return : 'a -> ('a, 'r) t | |
val (>>=) : ('a, 'r) t -> ('a -> ('b, 'r) t) -> ('b, 'r) t | |
end = struct | |
type ('a, 'r) t = ('a -> 'r) -> 'r | |
let return x = fun k -> k x | |
let (>>=) m f = fun k -> | |
m (fun a -> (f a) k) | |
end | |
module Continuation' : sig | |
type 'a t = { run : 'r . ('a -> 'r) -> 'r} | |
val return : 'a -> 'a t | |
val (>>=) : 'a t -> ('a -> 'b t) -> 'b t | |
end = struct | |
type 'a t = { run : 'r . ('a -> 'r) -> 'r} | |
let return x = { run = fun k -> k x} | |
let (>>=) m f = | |
let run k = | |
m.run (fun a -> (f a).run k) | |
in | |
{ run } | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment