module type OneSig = sig
type t
val oneValue: t -> string
end
module type TwoSig = sig
type t
val twoValue: t -> int
end
let hasBothOneAndTwo (implicit OneImpl: OneSig) (implicit TwoImpl: TwoSig with type t = OneImpl.t) (o : OneImpl.t) =
let twoValue = string_of_int (TwoImpl.twoValue o) in
let oneValue = OneImpl.oneValue o in
oneValue ^ twoValue
implicit module HasBothForAbstractFloat: sig
type t
val create: unit -> t
val oneValue: t -> string
val twoValue: t -> int
end = struct
type t = float
let create () = 4.4
let oneValue = string_of_float
let twoValue = int_of_float
end
let abstractFloat = HasBothForAbstractFloat.create ()
let _ = hasBothOneAndTwo abstractFloat
gives the error:
Error: Signature mismatch:
...
Type declarations do not match:
type t
is not included in
type t = HasBothForAbstractFloat.t
File "[5]", line 7, characters 7-8: Expected declaration
File "[5]", line 17, characters 7-8: Actual declaration
Characters 681-697:
let _ = hasBothOneAndTwo abstractFloat
^^^^^^^^^^^^^^^^
It seems that, for some reason, the final inclusion check ends up checking the strengthened version of the module type (the one including "type t = HasBothForAbstractFloat.t") against
the unstrengthed version (the one with just "type t").
A bug report from @jordwalke:
gives the error:
It seems that, for some reason, the final inclusion check ends up checking the strengthened version of the module type (the one including "type t = HasBothForAbstractFloat.t") against the unstrengthed version (the one with just "type t").