
6 Oct
2008
6 Oct
'08
8:06 p.m.
2008/10/6 Arnar Birgisson
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.