-
-
Save rostero1/330c9895cf0f8abe0f7065b781ac804b 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
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 | |
*) |
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
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