8.16. Control over monomorphism
Prev | Chapter 8. GHC Language Features | Next

## 8.16. Control over monomorphism

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

### 8.16.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`.

### 8.16.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
8.15. Generic classes | Home | 8.17. Concurrent and Parallel Haskell