Why is this allowed:
i :: Num a => a
i = 1
While none of these is allowed:
i' :: Num a => a
Just i' = Just 1
x, y :: Num a => a
(x, y) = (1, 2)
x :: Num a => a
y :: Num a => a
(x, y) = (1, 2)
y :: Num a => a
x :: Num a => a
(x, y) = (1, 2)
m :: ()
n :: Num a => a
(n, m) = (1, ())
n :: Num a => a
m :: ()
(n, m) = (1, ())
Unless turned off monomorphism restriction
by {-# LANGUAGE NoMonomorphismRestriction #-},
trying to compile with any of them always results in "Overloaded signature conflicts with monomorphism restriction".
But haven't I already specified all the types here? How could the monomorphism restriction even come up in the first place?
Quoth the rule:
What is a simple pattern binding though? There are two contradictory definitions.
and
According to the first definition, none of your failed bindings are simple, so they cannot be unrestricted, which means the mononorphism restriction applies to them. According to the second definition, all are simple and unrestricted, that is, the mononorphism restriction should not apply.
The applicable definition should be the first one as detailed in this posting and that's what the compiler is using, but AFAICT the report is not updated to reflect this.