Johan Holmquist <[EMAIL PROTECTED]> writes:

> > class Num b => Rect a b | a -> b where
> > instance Rect IRect Int where
> 
> However, I haven't been able to make PRect an instance of this class (with 
> extensions). I might not have grasped this yet, but I came to think; if the 
> old class declaration would say that "width" and "height" returns something 
> with unfixed type in the "Num" class, then wouldn't it be possible to make 
> PRect an instance of that class (since PRect has a type parameter)?
> 
> Something like this:
> 
> class Rect a where
>       width  :: (Num b) => a -> b
>       height :: (Num b) => a -> b
> 
> data Num a => PRect a = PRect (a, a) (a, a) deriving (Eq, Show)
> instance Rect PRect a where ...

I think this is just a bracketting problem.  With the second defn of
class Rect above, you probably mean

  instance Rect (PRect a) where ...

whereas if you were intending the earlier defn of class Rect, with
two type parameters, then you may mean

  instance Rect (PRect a) a where ...

Regards,
    Malcolm
_______________________________________________
Haskell mailing list
Haskell@haskell.org
http://www.haskell.org/mailman/listinfo/haskell

Reply via email to