| > This one is easy (I think) (for a change).  The module above is quite legal,
| > and exports the type T but not the constructor.  If you wanted the
| > constructor to go too, you can write
| >
| >     module M( T(..) )
| >
| > or
| >
| >     module M( T(T) )
| But, but, but, how can you say that this is legal so easily?
| Take this one:
|       module M(T) where
|       data S = T
| This is clearly illegal since it names a constructor in the export list.
| Then, what about:
|       module M(T) where
|       data S = T
|       data T = U
| Now T is a type, but also a constructor (in a different type).
|
| Is the general rule supposed to be that naming a constructor in
| an export list is OK if it is also a name of a type, synonym, or class?
| (And then it does not refer to the constructor.)
| I could live with this, but my enquireing mind wants to know!

You just can't name a constructor in an export list.  So if you say "T",
you can't mean the constructor T, you must mean the type or class T.

It's like saying "do you mean the type T or the constructor T?" in the
following definition of f:

        f (T x) = x

You could only mean the constructor T.  You wouldn't say "naming a type
in a pattern matching definition is OK if it is also the name of
a constructor too", would you?

Unless I'm missing something...

Simon


Reply via email to