In Hugs 1.4, ++ was an operator of class Monad; in Hugs 98 it is an operator on lists. I've looked in the Hugs documentation and haven't found anything about the change (probably a failing of mine, not the documentation). Anyway, that breaks some code in an article that's been accepted for JFP, wherein I overloaded ++ by placing the operand type in class Monad. This doesn't work any more. I don't want to publish code that doesn't work, and I don't want to give up that overloading, which is completely natural. Can you shed any light on what happened between the two versions? Or offer an idea about how to rescue the overloading? Many thanks, Doug McIlroy
On Thu, Oct 16, 2003 at 03:54:51PM -0400, Doug McIlroy wrote:
In Hugs 1.4, ++ was an operator of class Monad; in Hugs 98 it is an operator on lists. I've looked in the Hugs documentation and haven't found anything about the change (probably a failing of mine, not the documentation).
Anyway, that breaks some code in an article that's been accepted for JFP, wherein I overloaded ++ by placing the operand type in class Monad. This doesn't work any more.
I don't want to publish code that doesn't work, and I don't want to give up that overloading, which is completely natural. Can you shed any light on what happened between the two versions? Or offer an idea about how to rescue the overloading?
This was a change from Haskell 1.4 to Haskell 98, so it affects all Haskell implementations (to save beginners using lists from incomprehensible type errors). You'll need to put your type in the class class (Monad m) => MonadPlus m where mzero :: m a mplus :: m a -> m a -> m a and use `mplus` instead of ++.
hello, Ross Paterson wrote:
On Thu, Oct 16, 2003 at 03:54:51PM -0400, Doug McIlroy wrote:
In Hugs 1.4, ++ was an operator of class Monad; in Hugs 98 it is an operator on lists. I've looked in the Hugs documentation and haven't found anything about the change (probably a failing of mine, not the documentation).
Anyway, that breaks some code in an article that's been accepted for JFP, wherein I overloaded ++ by placing the operand type in class Monad. This doesn't work any more.
I don't want to publish code that doesn't work, and I don't want to give up that overloading, which is completely natural. Can you shed any light on what happened between the two versions? Or offer an idea about how to rescue the overloading?
This was a change from Haskell 1.4 to Haskell 98, so it affects all Haskell implementations (to save beginners using lists from incomprehensible type errors). You'll need to put your type in the class
class (Monad m) => MonadPlus m where mzero :: m a mplus :: m a -> m a -> m a
and use `mplus` instead of ++.
if you really want to use '++' instead of 'mplus' you could: import Prelude hiding ((++)) x ++ y = mplus x y hope this helps iavor -- ================================================== | Iavor S. Diatchki, Ph.D. student | | Department of Computer Science and Engineering | | School of OGI at OHSU | | http://www.cse.ogi.edu/~diatchki | ==================================================
Doug McIlroy writes: | In Hugs 1.4, ++ was an operator of class Monad; in Hugs 98 it is | an operator on lists. I've looked in the Hugs documentation and | haven't found anything about the change (probably a failing of | mine, not the documentation). | | Anyway, that breaks some code in an article that's been accepted | for JFP, wherein I overloaded ++ by placing the operand type in | class Monad. This doesn't work any more. | | I don't want to publish code that doesn't work, and I don't want | to give up that overloading, which is completely natural. Can | you shed any light on what happened between the two versions? | Or offer an idea about how to rescue the overloading? Hi. It was in the transition from Haskell 1.4 to Haskell 98 that (++) was taken out of class MonadPlus and became list-specific. I think it had something to do with simplifying error messages. MonadPlus is still there, but the overloaded operator in question is now called `mplus`. Regards, Tom
participants (4)
-
Doug McIlroy -
Iavor Diatchki -
Ross Paterson -
Tom Pledger