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:
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
: 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
?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
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
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 =
] 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
:[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
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)
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
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 =
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)
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.
13 matches
Mail list logo