[Haskell-cafe] a really juvenile question .. hehehehe ;^)

Cale Gibbard cgibbard at gmail.com
Mon Oct 6 20:06:13 EDT 2008

2008/10/6 Arnar Birgisson <arnarbi at gmail.com>:
> Ah, that's pretty neat and subtle. Now, say I have a type created with
> data that has only one constructor. Couldn't the compiler optimize
> away this unneccessary evaluation during pattern matching? I.e. it
> would make what you just wrote implicit in that case. Or perhaps data
> declarations with just one ctor should really be turned into newtypes
> by the programmer?

Well, the trouble is that because there are differences in the
termination behaviour of programs depending on whether something is a
newtype or a data with a single constructor, I think automatic
conversion of one to the other is avoided.

More information about the Haskell-Cafe mailing list