[Haskell-cafe] OOP'er with (hopefully) trivial questions.....
Evan Laforge
qdunkan at gmail.com
Mon Dec 17 13:17:07 EST 2007
> A newtype can only have one constructor, with one argument, and is
> essentially a wrapper for that argument type.
>
> In the general case, you want to use "data" instead of "newtype":
>
> data Rectangle = R Int Int
I'm sure there's a trivial explanation for this, but here's something
that I've always kind of wondered about: Given a single constructor
type like "data X = X A B C" can't that be transformed into "newtype X
= X (A, B, C)"? There must be some difference, because if there
weren't we could transform all single constructor types that way, and
dispense with newtype entirely.
More information about the Haskell-Cafe
mailing list