Skip to content

Instantly share code, notes, and snippets.

@rostero1

rostero1/file.ml Secret

Last active July 8, 2018 19:05
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 rostero1/330c9895cf0f8abe0f7065b781ac804b to your computer and use it in GitHub Desktop.
Save rostero1/330c9895cf0f8abe0f7065b781ac804b to your computer and use it in GitHub Desktop.
type record = {
field: string;}
type on
type off
module type Thing =
sig
type ('a,'p) t
val create : 'a -> ('a,on) t
val run : ('a,off) t -> ('a,on) t
end
module Thing : Thing =
struct
type ('a,'p) t = record
let run (r : ('a,'p) t) = let value = r.field in r
let create r = r
end
let record1 = { field = "foo" }
let a = Thing.create record1
let b = Thing.run a
(*
Signature mismatch:
...
Values do not match:
val create : 'a -> 'a
is not included in
val create : 'a -> ('a, on) t
*)
type record = {
field: string;}
type on
type off
module type Thing =
sig type 'a t val create : record -> off t val run : off t -> on t end
module Thing : Thing =
struct
type 'a t = record
let run r = let value = r.field in r
let create r = r
end
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