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

## 7.14. Control over monomorphism

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

### 7.14.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 `-fno-monomorphism-restriction`.

### 7.14.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 `-fno-mono-pat-binds` to recover the standard behaviour.

Prev | Up | Next
7.13. Generic classes | Home | 7.15. Concurrent and Parallel Haskell