| When I was trying to sleep last night I though I could implement Search
 | Trees in Haskell.
 | And not only that, I would try to implement them as monads.
 | The problem is that search trees require context Ord a.

Since noone has replied to this yet, I will give a short explanation.

A Monad is defined as a type contructor M, together with operators bind
and return, for which some laws hold. The type for result, for example,
is:

  return :: All a => a -> M a

This means that your search tree is not a monad! At least not according to
this definition. You return operator would have type:

  return :: Ord a => a -> M a

Since Haskell uses this definition of a monad, you can't define this in
Haskell either.

Regards,
Koen.

--
Koen Claessen,
[EMAIL PROTECTED],
http://www.cs.chalmers.se/~koen,
Chalmers University of Technology.



Reply via email to