(no subject)

David Feuer David_Feuer@brown.edu
Fri, 25 Jan 2002 2:27:05 -0500


Martin Said:

> Those two constructs are not the same

> Compare

> newtype T1 = C1 Bool
>  data    T2 = C2 !Bool

> the difference is that the constructor C1 does not 
exist, so only the following values exist for T1:

> C1 True  (which is the represented as True)
> C1 False (which is the represented as False)
> C1 _|_   (which is represented as non-termination or 
error)

> however, for T2, another value exist, namely _|_.
> So, pattern matching on (T2 x) may fail it the value is 
> _|_. You are
> right that semantically newtype is the same as always 
matching lazily on the constructor.

The report says clearly that for a newtype like T1,
C1 _|_ = _|_
This is the same as for T2 and C2.
As for as I can tell, the only difference in the Report 
between a newtype and a tuple type with a completely 
strict constructor is in the rules for pattern matching.  
So I am trying to find someone who can explain the reason 
for the difference in the rules!  I really want to know, 
because I think/hope that it will help me understand 
certain things about how to write efficient code.

> The case for a tuple type (a,b,c) for instance, is 
different. Here there
> is a constructor, you can even type it by itself, it is 
> (,,), try ":t
> (,,)" in hugs or ghci.

I don't understand what you're talking about here.... Of 
course there's a constructor...

This message has been brought to you by the letter alpha and the number pi.