Skip to content

Instantly share code, notes, and snippets.

@cemerick cemerick/poly.ml
Last active Feb 20, 2019

Embed
What would you like to do?
(****** works ******)
type foo = [`A of int | `B of int]
module type K = sig
type t
val value: t -> int
end
module J (K: K) = struct
let value = K.value
end
module FooJ = J(struct
type t = foo
let value = function | `A r -> r | `B r -> r
end)
(****** doesn't work ******)
type aa = {value: int}
type bb = {value: int}
type foo = [`A of aa | `B of bb]
module type K = sig
type t
val value: t -> int
end
module J (K: K) = struct
let value = K.value
end
module FooJ = J(struct
type t = foo
let value = function | `A r -> r.value | `B r -> r.value
end)
(*
Error: Signature mismatch:
Modules do not match:
sig type t = foo val value : [< `A of bb | `B of bb ] -> int end
is not included in
K
Values do not match:
val value : [< `A of bb | `B of bb ] -> int
is not included in
val value : t -> int
*)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.