On 14/06/05, Adde <[EMAIL PROTECTED]> wrote:
> While we're at it, I tried adding a class Length in between Unit and Meter, 
> like
> this:
> 
> class Unit u where
>     shortName :: u -> String
> 
> class (Unit u) => Length u
> 
> instance Length Meter where
>     shortName u = "m"
> 
> >From the information I can find on the web subclassing should include all
> of the methods in the superclasses but I get this error:
> 
> `shortName' is not a (visible) method of class `Length'
> 

It's saying that shortName isn't a method of the class Length, which
is right, it's a method of the class Unit, so you should put it in the
Unit instance rather than in the Length instance.

The declarations in an instance of a class C may contain bindings only
for the class methods of C. The class methods of C are exactly those
whose type signatures are given in the class declaration of C (which
may not overlap with other class declarations or top level bindings).

> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe@haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to