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

Jules Bean jules at jellybean.co.uk
Tue Dec 18 05:03:15 EST 2007


Miguel Mitrofanov wrote:
>> class Shape a where {
> 
>>    intersect :: Shape b => a -> b -> Bool
> 
>> }
> 
>> data Shape a = { intersect :: Shape b => a -> b -> Bool }
> 
>> in fact, the syntax is rather similar, too! :)
> 
> 
> 
> Um, well, and how are you going to implement it?


Yes, exactly.

My only point is

There is no difference!

There is no difference between the manual dictionary approach and the 
typeclass approach, in terms of ease of implementing a binary function. 
Each one has the same fundamental problem: binary functions are much 
easier with the ADT approach.

Incidentally, my type sig was wrong, sorry:

data Shape a  = { intersect :: a -> Shape b -> Bool }

Jules



More information about the Haskell-Cafe mailing list