[Haskell-cafe] is monomorphism restriction necessary?
Alexey Muranov
alexey.muranov at gmail.com
Sat Apr 16 11:53:47 UTC 2016
Sorry for the question that probably is already answered somewhere, but i do not get it from the basic documentation i have looked at so far.
Is monomorphism restriction really necessary, or is it just a convenience?
In the example from A History of Haskell
genericLength :: Num a => [b] -> a
f xs = (len, len)
where
len = genericLength xs
can't the monomorphism restriction be replaced with just adding the signature
f :: Num a => [b] -> (a, a)
?
If yes, are there other cases where there is no way to get the desired behavior without enabling the monomorphism restriction?
Alexey.
More information about the Haskell-Cafe
mailing list