haskell - Overlapping instances ok, but still fails -
when enter following in haskell:
{-# language flexibleinstances, overlappinginstances, undecidableinstances #-} class class instance class instance eq => class
i error when load ghci:
test.hs:5:10: duplicate instance declarations: instance [overlap ok] class -- defined @ test.hs:5:10 instance [overlap ok] eq => class -- defined @ test.hs:6:10 failed, modules loaded: none.
i sort of understand why failing, seeing both instances a
, neither more specific, assuming constraints ignored. why saying overlap ok?
also, possible add language extension allow these kinds of overlap work , useful?
and finally, intend possible in current ghc in way (what intend use 1 piece of code instances of eq
, rest)?
"but why saying overlap ok?"
because told language pragma.
note these instances not merely overlapping, identical, far ghc's instance resolution concerned. ghc knows no way @ ever distinguish these instances, hence rejects them. not incoherentinstances
helps ghc yet. in ghc 7.8, joachim breitner just notified me.
and finally, intend possible in current ghc in way (what intend use 1 piece of code instances of
eq
, rest)?
i not surprised if new costraint kinds extensions make possible, i've never worked them, don't know how work , can do. code not simple, if works @ all.
Comments
Post a Comment