[Haskell-cafe] OOP'er with (hopefully) trivial questions.....

Stuart Cook scook0 at gmail.com
Mon Dec 17 06:59:47 EST 2007

On Dec 17, 2007 10:47 PM, Nicholls, Mark <Nicholls.Mark at mtvne.com> wrote:
> "The constructor of a newtype must have exactly one field   but `R' has
> two In the newtype declaration for `Rectangle'"
> It doesn't like
> "newtype Rectangle = R Int Int"

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


More information about the Haskell-Cafe mailing list