Skip to content

Instantly share code, notes, and snippets.

@cemerick
Last active February 20, 2019 20:11
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 cemerick/387dfea24877d4547974bdb565a6223a to your computer and use it in GitHub Desktop.
Save cemerick/387dfea24877d4547974bdb565a6223a to your computer and use it in GitHub Desktop.
(****** 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