Skip to content

Instantly share code, notes, and snippets.

@steinuil

steinuil/test.ml Secret

Created July 8, 2018 19:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save steinuil/12e82304e5bce1badde3f9561cb1ef45 to your computer and use it in GitHub Desktop.
Save steinuil/12e82304e5bce1badde3f9561cb1ef45 to your computer and use it in GitHub Desktop.
module type Thing = sig
type 'a off
type 'a on
val create : 'a -> 'a off
val run : 'a off -> 'a on
end
module Thing : Thing = struct
type 'a off = Off of 'a
type 'a on = On of 'a
let create x = Off x
let run (Off x) =
(* ... *)
On x
end
type record = { field : string }
let record1 = { field = "foo" }
let a = Thing.create record1
let b = Thing.run a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment