I'm just trying to pick up the basics....and I've managed to write this
code...which remarkably works......
module Main where
data SquareType = SquareConstructor Int
class ShapeInterface shape where
area :: shape->Int
data ShapeType = forall a. ShapeInterface a => ShapeType a
instance ShapeInterface SquareType where
area (SquareConstructor sideLength) = sideLength * sideLength
main = do
putStrLn (show (area (SquareConstructor 4)))
name <- getLine
putStrLn ""
But my next iteration was to try to parametise SquareType....
So something like
data SquareType a = Num a => SquareConstructor a
but of course doing this breaks everything.......sepecifically the
instance declaration
`SquareType' is not applied to enough type arguments
Expected kind `*', but `SquareType' has kind `* -> *'
In the instance declaration for `ShapeInterface SquareType'
And I can't seem to get it to work.....
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe