
On Fri, 31 Aug 2001 22:24:06 +0300, Cagdas Ozgenc wrote:
class Ord a where (<) :: a -> a -> Bool
data Set a = Ord a => [...]
The only thing that bothers me here is the Asymmetry. The syntax treats the first, and the second argument differently.
Not really, except for the order not being commutative (same as in C++).
Although there is equal emphasis on both "a"s in an "<" operation. C++ solves this problem by taking them out of the class.
bool operator < (const Ord& a, const Ord& b);
where arguments are treated with equal rights. Maybe I am just too concerned.
I don't know if I follow your exact concern. In any case, I just thought that you can always do in Haskell something like this: equals :: (Eq a, Eq b) => a -> b -> Bool a ´equals´ b = [...] -- I don't know how to implement this which is something like what you want, except that the definition that you put on that function MUST serve for all appropriate types. In Haskell, you can't add overloads to a function unless that function belongs to a class. Then you can make overloads by making different instances of that class. That has trade-offs over the C++ system, like: - Code is more organized the Haskell way. Easier on the compiler tools. - Programs and modules are more predictable in Haskell, because what they define cannot be 'modified'. - C++ allows dynamic inheritance, which is best in some situations. In Haskell you have to hack it in. - C++ has more flexible static overloading. What can I say? My favorite programming language hasn't been invented yet. But I'm sure it'll borrow concepts from both, Haskel and C++. I like Patrick's little talk about concepts a lot better than anything I said, BTW. It's like the GCC extension of signatures, in a way. Salutaciones, JCAB email: jcab@roningames.com ICQ: 101728263 The Rumblings are back: http://www.JCABs-Rumblings.com