[Haskell-cafe] OOP'er with (hopefully) trivial questions.....

Felipe Lessa felipe.lessa at gmail.com
Tue Dec 18 07:24:58 EST 2007


On Dec 18, 2007 7:51 AM, Jules Bean <jules at jellybean.co.uk> wrote:
> class Shape a where {
>    intersect :: Shape b => a -> b -> Bool
> }

Shouldn't this be

class Shape a where
  ....whatever....

class (Shape a, Shape b) => Intersectable a b where
  intersect :: a -> b -> Bool

With your definition I don't see how you could make it work, as you
would have to write a function that takes care of this shape
intersecting with any other shape, but this is exactly the problem the
classes should solve!

Cheers,

-- 
Felipe.


More information about the Haskell-Cafe mailing list