
15 Oct
2005
15 Oct
'05
1:03 p.m.
Wolfgang Jeltsch wrote:
Am Samstag, 15. Oktober 2005 08:31 schrieb Bulat Ziganshin:
Hello Haskell,
number of type definition statements in Haskell (data, type, newtype) is a bit too large. at least, newtype definition seems to be superfluous - it can be replaced by the same `data` definition:
newtype A = A Int and data A = A Int
is equal, excluding for internal representation.
This is not true. With newtype, A _|_ is _|_, with data, A _|_ is not _|_. But as far as I know, the above newtype declaration is equivalent to this:
data A = A !Int
Alas, Haskell is more subtle than that. Which is why newtype exists. Try case A _|_ of A _ -> 1 with the two versions of A to see the difference. -- Lennart