Let's do ListT right, finally
Hi Ian, thanks for responding to my plea! I am renaming this thread and moving it to libraries. Please respond there. I wrote:
http://haskell.org/haskellwiki/ListT_done_right and not the broken implementation that comes with mtl. (Finally fixed in 6.8? Please?)
Ian Lynagh wrote:
If you want to propose that mtl switches to a different definition of ListT then please see http://www.haskell.org/haskellwiki/Library_submissions
OK, then. This is a major rewrite of this module. So let me open up the topic for discussion even before posting a submission. Do we need to worry about breaking code? Not very much, I suspect. That "monad" really is broken - it's not a monad at all. The problem and its solution have been well known for years. I personally tried using the "standard" ListT for a while, just because it's the standard. Until I ran into enough problems that I finally slapped my forehead and said "forget it". But just in case: Is there anyone reading this who would be hurt by this change and opposes it? Should we provide a more gradual deprecation path (what is it)? Thanks, Yitz
On 10/14/07, Yitzchak Gale
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. The replacement ListT is usually the monad transformer I need when I want a List-like monad transformer, so I'm all for it being in the standard prelude. But it seems sad there isn't a place for the old one to live. -- Dan
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
David Menendez wrote:
Dan Piponi wrote:
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.
While possible, it's not really worth it since the commutative ListT and the general ListT coincide when applied to commutative monads. In other words, the new ListT is strictly more general than the old one and thus preferred. Regards, apfelmus
participants (4)
-
apfelmus -
Dan Piponi -
David Menendez -
Yitzchak Gale