Sebastian suggests using some syntax other than pattern
matching to express the isomorphism involved in a newtype.
I can't see any advantage in this.
Further, Simon PJ claims that if someone has written
data Age = Age Int
foo (Age n) = (n, Age (n+1))
that we want to be able to
Well, I'm glad to see I provoked some discussion!
Simon writes:
Lennart writes:
| So if we had
|
|data Age = Age !Int
|foo (Age n) = (n, Age (n+1))
|
| it would translate to
|
|foo (MakeAge n) = (n, seq MakeAge (n+1))
|
| [makeAge is the
Lennart writes:
| So if we had
|
| data Age = Age !Int
| foo (Age n) = (n, Age (n+1))
|
| it would translate to
|
| foo (MakeAge n) = (n, seq MakeAge (n+1))
|
| [makeAge is the "real" constructor of Age]
|
| Now, surely, seq does not evaluate its first argument when the
On Tue, 12 Sep 1995, Lennart Augustsson wrote:
The posted semantics for strict constructors, illustrated by this example
from the Haskell 1.3 post, is to insert seq.
data R = R !Int !Int
R x y = seq x (seq y (makeR x y)) -- just to show the semantics of R
So if we had
The design of newtype appears to me incorrect.
The WWW page says that declaring
newtype Foo = Foo Int
is distinct from declaring
data Foo = Foo !Int
(where ! is a strictness annotation) because the former gives
case Foo undefined of Foo _ - True = True
and the