Version 3 (modified by Simon Peyton Jones, 11 years ago) (diff)

Make pattern bindings monomorphic

Proposal: make all pattern bindings completely monomorphic (regardless of type signatures)

At the moment you can say

	let (f,g) = e in ...

and get *polymorphic* values f,g. This causes a good deal of trouble in the implementation (think of what the System F translation looks like), and it's an odd thing to do. Why odd? Well here it's fine:

	data T = C (forall a. a->a)
	h x = let C f = e in ...

Constructor C has a polymorphic argument, so we can match e against (C f) and get a polymorphic function. But in the first example, (,) only takes monomorphic arguments, so we have to generalise after selection. To put it another way, even if the "…" is definitely strict in f, we cannot transform to

	case e of (f,g) -> ...

So this proposal makes the bang-pattern proposal easier to describe


In July I changed GHC (the HEAD) to make pattern bindings monomorphic by default. (A binding of a simple variable is not considered to be a pattern binding.) The flag -fno-mono-pat-binds restores the standard behaviour.

The interesting observation is this: all of the libraries compile without a tremor, and I have received no mail whatsoever complaining about the new behaviuor. I deliberated made the new behaviour the default so that I'd hear of any breakaga.

My conclusion: polymorphic pattern bindings is a feature that is virtually never used. We should nuke them.