7.17. Control over monomorphism
Prev | Chapter 7. GHC Language Features | Next

## 7.17. Control over monomorphism

GHC supports two flags that control the way in which generalisation is carried out at let and where bindings.

### 7.17.1. Switching off the dreaded Monomorphism Restriction

Haskell's monomorphism restriction (see Section 4.5.5 of the Haskell Report) can be completely switched off by `-XNoMonomorphismRestriction`.

### 7.17.2. Monomorphic pattern bindings

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 `-XNoMonoPatBinds` to recover the standard behaviour.

Prev | Up | Next
7.16. Generic classes | Home | 7.18. Concurrent and Parallel Haskell