The dreaded M-R
rjmh at cs.chalmers.se
Tue Jan 31 09:43:36 EST 2006
"Simon Marlow" <simonmar at microsoft.com> writes:
>> Given the new evidence that it's actually rather hard to demonstrate any
>> performance loss in the absence of the M-R with GHC, I'm attracted to
>> the option of removing it in favour of a warning.
As another data point, today for the first time I received an error
(not a warning) from ghc about the M-R:
Ambiguous type variable `a' in the constraint:
`Ord a' arising from use of `Data.Set.insert' at Pretty.hs:28:11-20
Possible cause: the monomorphism restriction applied to the following:
addToSet :: a -> Data.Set.Set a -> Data.Set.Set a (bound at
Probable fix: give these definition(s) an explicit type signature
or use -fno-monomorphism-restriction
So, without the M-R or a type signature, my code is OK. The proposal
to accept this code but produce an optional warning is (I think)
better than the current error.
Well, is it OK? From the type-checker's point of view, yes, But have you lost
sharing? Have you introduced a space leak, because a seq on one of the occurrences
of your variable only forces one instance? Those are the dangers of following the
advice to put a type signature in.
More information about the Haskell-prime