Re: [Haskell-cafe] Let's do ListT right, finally

On 10/14/07, Dan Piponi
On 10/14/07, Yitzchak Gale
wrote: Not very much, I suspect. That "monad" really is broken - it's not a monad at all.
Depending on your point of view, ListT isn't broken. It correctly transforms commutative monads into monads. The problem is that you can't express "commutative monad" any differently from "monad" in Haskell. And so it's been shoehorned into the wrong type class.
If desired, we could easily define a class for commutative monads, and
then state that ListT m is only a monad if m is a commutative monad.
For example,
class Monad m => CommutativeMonad m
instance (CommutativeMonad m) => Monad (ListT m) where
return a = ListT (return [a])
etc.
Naturally, it's up to the programmer to guarantee that instances of
CommutativeMonad are actually commutative monads.
--
Dave Menendez

David Menendez wrote:
If desired, we could easily define a class for commutative monads, and then state that ListT m is only a monad if m is a commutative monad.
If we do that, can I suggest that we use some name other than ListT for that? So far, we seem to agree that most practical applications use the new ListT. Thanks, Yitz
participants (2)
-
David Menendez
-
Yitzchak Gale