Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inclusion check failing #45

Open
lpw25 opened this issue Dec 30, 2015 · 0 comments
Open

Inclusion check failing #45

lpw25 opened this issue Dec 30, 2015 · 0 comments

Comments

@lpw25
Copy link
Member

lpw25 commented Dec 30, 2015

A bug report from @jordwalke:

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").

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant