GHC supports two flags that control the way in which generalisation is carried out at let and where bindings.
Haskell's monomorphism restriction (see
Section
4.5.5
of the Haskell Report)
can be completely switched off by
-XNoMonomorphismRestriction
.
As an experimental change, we are exploring the possibility of making pattern bindings monomorphic; that is, not generalised at all. A pattern binding is a binding whose LHS has no function arguments, and is not a simple variable. For example:
f x = x -- Not a pattern binding f = \x -> x -- Not a pattern binding f :: Int -> Int = \x -> x -- Not a pattern binding (g,h) = e -- A pattern binding (f) = e -- A pattern binding [x] = e -- A pattern binding
Experimentally, GHC now makes pattern bindings monomorphic by
default. Use -XMonoPatBinds
to recover the
standard behaviour.