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

David Menendez dave at zednenem.com
Fri Dec 21 12:04:46 EST 2007

On Dec 21, 2007 11:50 AM, Nicholls, Mark <Nicholls.Mark at mtvne.com> 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 only to the data constructor.

That is, given an unknown value of type SquareType a for some a, we do not
have enough information to infer Num a.

For your code, you want something like:

instance (Num a) => ShapeInterface (SquareType a) where
    area (SquareConstructor side) = side * side

Dave Menendez <dave at zednenem.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20071221/27d09509/attachment-0001.htm

More information about the Haskell-Cafe mailing list