Questions about sharing

Simon Peyton-Jones
Fri, 7 Dec 2001 08:20:36 -0800

| Does the compiler keep a unique copy of expressions which=20
| consist of just a single zero arity constructor (eg.=20
| [],True,Nothing..) as a CAF which is referenced each time the=20
| constructor appears in an expression

Yes, it does.

| The second is..
| If, following pattern matching, the matched pattern appears=20
| in an expression, is it shared or duplicated.. e.g. (a:as) ->=20
| f (a:as) Maybe I should write something like this..
|      x@(a:as) -> f x
| (I know that sometimes the type checker won't allow you to do this)

The compiler will share it if you are using -O; but only if the type
checker would also allow it.  (The internal language is typed!)