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