Re: [Haskell-cafe] nice simple problem for someone struggling....

2007-12-21 Thread Jules Bean
Nicholls, Mark wrote: *instance* ShapeInterface SquareType *where* area (SquareConstructor sideLength) = sideLength * sideLength *data* SquareType a = Num a = SquareConstructor a Now you have changed your type from SquareType to SquareType a, you need to change the instance to:

RE: [Haskell-cafe] nice simple problem for someone struggling....

2007-12-21 Thread Nicholls, Mark
ReallyI'm sure I tried that...(as it seemed obvious) ... and it failedbut I'll have another go -Original Message- From: Jules Bean [mailto:[EMAIL PROTECTED] Sent: 21 December 2007 15:33 To: Nicholls, Mark Cc: haskell-cafe@haskell.org Subject: Re: [Haskell-cafe] nice simple

RE: [Haskell-cafe] nice simple problem for someone struggling....

2007-12-21 Thread Nicholls, Mark
: Jules Bean [mailto:[EMAIL PROTECTED] Sent: 21 December 2007 15:33 To: Nicholls, Mark Cc: haskell-cafe@haskell.org Subject: Re: [Haskell-cafe] nice simple problem for someone struggling Nicholls, Mark wrote: *instance* ShapeInterface SquareType *where* area (SquareConstructor sideLength

RE: [Haskell-cafe] nice simple problem for someone struggling....

2007-12-21 Thread Nicholls, Mark
?if notwhy not? From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of David Menendez Sent: 21 December 2007 17:05 To: Nicholls, Mark Cc: Jules Bean; haskell-cafe@haskell.org Subject: Re: [Haskell-cafe] nice simple problem for someone struggling

Re: [Haskell-cafe] nice simple problem for someone struggling....

2007-12-21 Thread David Menendez
On Dec 21, 2007 11:50 AM, Nicholls, Mark [EMAIL PROTECTED] wrote: Now I have module Main where data SquareType numberType = Num numberType = SquareConstructor numberType This is a valid declaration, but I don't think it does what you want it to. The constraint on numberType applies

Re: [Haskell-cafe] nice simple problem for someone struggling....

2007-12-21 Thread Brent Yorgey
class ShapeInterface shape where area :: shape-Int now looks dubiousI want it to be something like class ShapeInterface shape where area :: Num numberType = shape-Int ? Rather, I think you probably want class ShapeInterface shape where area :: Num numberType =

RE: [Haskell-cafe] nice simple problem for someone struggling....

2007-12-21 Thread Nicholls, Mark
] nice simple problem for someone struggling class ShapeInterface shape where area :: shape-Int now looks dubiousI want it to be something like class ShapeInterface shape where area :: Num numberType = shape-Int

RE: [Haskell-cafe] nice simple problem for someone struggling....

2007-12-21 Thread Nicholls, Mark
:[EMAIL PROTECTED] On Behalf Of David Menendez Sent: 21 December 2007 17:05 To: Nicholls, Mark Cc: Jules Bean; haskell-cafe@haskell.org Subject: Re: [Haskell-cafe] nice simple problem for someone struggling On Dec 21, 2007 11:50 AM, Nicholls, Mark [EMAIL PROTECTED] wrote: Now I have

Re: [Haskell-cafe] nice simple problem for someone struggling....

2007-12-21 Thread Miguel Mitrofanov
module Main where data SquareType numberType = Num numberType = SquareConstructor numberType class ShapeInterface shape where area :: Num numberType = shape-numberType data ShapeType = forall a. ShapeInterface a = ShapeType a instance (Num a) = ShapeInterface (SquareType a)

Re: [Haskell-cafe] nice simple problem for someone struggling....

2007-12-21 Thread David Menendez
On Dec 21, 2007 12:08 PM, Nicholls, Mark [EMAIL PROTECTED] wrote: I thought from Num numberType = SquareConstructor numberType We could deduce that (in English rather than get Haskell and FOL confusion) all values of SquareConstructor a….the type of a would have be be in class

Re: [Haskell-cafe] nice simple problem for someone struggling....

2007-12-21 Thread David Menendez
On Dec 21, 2007 12:47 PM, Nicholls, Mark [EMAIL PROTECTED] wrote: Let me resend the code…as it stands…. *module* Main *where* *data* SquareType numberType = Num numberType = SquareConstructor numberType *class* ShapeInterface shape *where* area :: Num numberType =

Re: [Haskell-cafe] nice simple problem for someone struggling....

2007-12-21 Thread Jules Bean
David Menendez wrote: That's a reasonable thing to assume. It just happens that Haskell doesn't work that way. There's an asymmetry between constructing and pattern-matching, and it's one that many people have complained about. With GADTs turned on (-XGADTS in 6.8, -fglasgow-exts in 6.6)

Re: [Haskell-cafe] nice simple problem for someone struggling....

2007-12-21 Thread David Menendez
On Dec 21, 2007 2:38 PM, Jules Bean [EMAIL PROTECTED] wrote: David Menendez wrote: That's a reasonable thing to assume. It just happens that Haskell doesn't work that way. There's an asymmetry between constructing and pattern-matching, and it's one that many people have complained about.