You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
module type OneSig=sigtypetvaloneValue: t -> stringendmodule type TwoSig=sigtypetvaltwoValue: t -> intendlethasBothOneAndTwo{OneImpl: OneSig}{TwoImpl: TwoSig with type t = OneImpl.t}o=let twoValue = string_of_int (TwoImpl.twoValue o) inlet oneValue =OneImpl.oneValue o in
oneValue ^ twoValue
implicit moduleHasBothForInt=structtypet = intletcreate()=0letoneValuet= string_of_int t
lettwoValuet= t
end
implicit moduleHasBothForFloat=structtypet = floatletcreate()=0.0letoneValuet= string_of_float t
lettwoValuet= int_of_float t
endlet _ = hasBothOneAndTwo 4
gives the error:
Error: Ambiguous implicit OneImpl: HasBothForFloat and HasBothForInt are both solutions.
are not handled correctly. Constraints generated by the TwoImpl.t
parameter are not propogated to the OneImpl implicit parameter. Since
the implicit parameters are currently searched left-to-right (at some
point we will make the search order-independent anyway, and then this
bug will be less noticable) the search for OneImpl fails as ambiguous.
There is a work-around, functions with types like:
do not suffer from this problem, so adding a type annotation fixes the issue:
lethasBothOneAndTwo{OneImpl: OneSig}{TwoImpl: TwoSig with type t = OneImpl.t} (o: OneImpl.t) =let twoValue = string_of_int (TwoImpl.twoValue o) inlet oneValue =OneImpl.oneValue o in
oneValue ^ twoValue
The text was updated successfully, but these errors were encountered:
A bug report from @jordwalke:
gives the error:
This is because functions with types like:
are not handled correctly. Constraints generated by the
TwoImpl.t
parameter are not propogated to the
OneImpl
implicit parameter. Sincethe implicit parameters are currently searched left-to-right (at some
point we will make the search order-independent anyway, and then this
bug will be less noticable) the search for
OneImpl
fails as ambiguous.There is a work-around, functions with types like:
do not suffer from this problem, so adding a type annotation fixes the issue:
The text was updated successfully, but these errors were encountered: