On Fri, 2008-09-26 at 15:25 -0700, Jason Dusek wrote:
> Can someone explain, why is it that Set can not be a Monad?

It can't even be a functor (which all monads are).  You can't implement

    fmap (+) $ Set.fromList [1, 2, 3]

with Data.Set, because you can't order functions of type Integer ->
Integer in a non-arbitrary way.  So you can't have a balanced binary
tree of them in a non-arbitrary way, either.  Something like

    fmap putStrLn $ Set.fromList ["Hello", "world"]

is similar.

Since Data.Set is implemented in Haskell, it can only use facilities
available to Haskell libraries.  So it can't work for arbitrary
elements; but a Functor instance requires that it does work.

jcc


_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to