Ok... Thanks I need to revisit data and newtype to work out what the difference is I think.
-----Original Message----- From: Jed Brown [mailto:[EMAIL PROTECTED] On Behalf Of Jed Brown Sent: 17 December 2007 12:04 To: Nicholls, Mark Cc: haskell-cafe@haskell.org Subject: Re: [Haskell-cafe] OOP'er with (hopefully) trivial questions..... On 17 Dec 2007, [EMAIL PROTECTED] wrote: > Ooo > > "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" You want data Rectangle = R Int Int A newtype declaration will be completely erased at compile time. That is, when you have a declaration like newtype Circle = C Int the compiled code will not be able to distinguish between a Circle and an Int. You do, however, get all the benefits of a separate entity in the type system. When your type only has one constructor, newtype is preferred over data, but they are semantically equivalent. There are extensions which provide impressive newtype-deriving-foo (getting the compiler to write fairly non-trivial instance declarations for you). Jed _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe