At 01:58 -0800 1998/11/09, Simon Peyton-Jones wrote:
Following many protests, the right thing to do seems
to be to move MonadPlus to the Monad library. Specifically:
class Monad m = MonadPlus m where
mzero :: m a
mplus :: m a - m a - m a
It seems me that the
Following many protests, the right thing to do seems
to be to move MonadPlus to the Monad library. Specifically:
class Monad m = MonadPlus m where
mzero :: m a
mplus :: m a - m a - m a
filterM :: MonadZero m = (a - m Bool) - [a] - m [a]
guard ::
Hi Alex,
Ok, then I am officially complaining about the elimination of ++ and
MonadPlus. It is a much more radical change than changing default
default and it will break a lot of MY code at very least.
The existing implementation in hugs allows you to write extremely concise
and clean code.
OK, I think we have enough agreement to decide:
class Monad m where
return :: m a
(=) :: m a - (a - m b) - m b
() :: m a - m b - m b
fail :: String - m a
fail s = error s
(I'm still a bit nervous about capturing 'fail' but
there
class Monad m where
return :: m a
(=) :: m a - (a - m b) - m b
() :: m a - m b - m b
fail :: String - m a
fail s = error s
IO.fail becomes IO.ioError
Looks good.
class Monad m = MonadPlus m where
mzero :: m
| class Monad m = MonadPlus m where
| mzero :: m a
| mplus :: m a - m a - m a
|
| Why is this here? It doesn't need to be in the prelude. Just
| leave it for the user to define (and then the user may pick
| better names, like Ringad, zero, and +). -- P
Yes, nuke
Philip Wadler wrote:
class Monad m = MonadPlus m where
mzero :: m a
mplus :: m a - m a - m a
Why is this here? It doesn't need to be in the prelude. Just
leave it for the user to define (and then the user may pick
better names, like Ringad, zero, and +). --
| class Monad m = MonadPlus m where
| mzero :: m a
| mplus :: m a - m a - m a
|
| Why is this here? It doesn't need to be in the prelude. Just
| leave it for the user to define (and then the user may pick
| better names, like Ringad, zero, and +). -- P
Yes, nuke
Does this mean that code which relies on ++ and do notation with Maybe
will stop working?
-Alex-
On Fri, 6 Nov 1998, Simon Peyton-Jones wrote:
| class Monad m = MonadPlus m where
| mzero :: m a
| mplus :: m a - m a - m a
|
| Why is this here? It doesn't need to be in the
Simon Peyton-Jones wrote:
Phil's proposal:
delete class MonadZero, MonadPlus
delete filterM, guard, mfilter, concatM
This is ok by me. Does anyone object?
Simon
If you're going to do this, are you going to change the Maybe library so
that it has something equivalent to
| Does this mean that code which relies on ++ and do notation with Maybe
| will stop working?
++ is specialized to lists, I'm afraid.
Ralf
This is ok by me. Does anyone object?
I don't understand why MonadZero/MonadPlus should go away.
Isn't the idea that when in doubt Haskell 98 should do
what Haskell 1.4 did? What's the compelling reason for
removing these classes? I've used several of the functions
that would go away. It
Yes, nuke MonadPlus. For Haskell 2 we can put these things in a
wonderful Monad library.
I had thought that too many functions depend on MonadZero/Plus,
but actually, it's the following:
filterM :: MonadZero m = (a - m Bool) - [a] - m [a]
guard :: MonadZero m = Bool - m ()
mfilter
Phil's proposal:
delete class MonadZero, MonadPlus
delete filterM, guard, mfilter, concatM
This is ok by me. Does anyone object?
No, not at all. The prelude should be as small as possible.
Erik
There is no need to have both `mzero' and `mfail' in every monad.
Just have `mfail'. Leave `zero' and `plus' to MonadPlus. This should
make Eric partially happy. It also means one can simply write
instance Monad [] where
...return, =, as before...
mfail s = []
Option 1: Monad( .., mfail, mzero ), MonadPlus( mplus )
Option 2: Monad( .., mfail), MonadPlus( mzero, mplus )
Option 3: Monad( .., mfail), MonadPlus( mplus ), MonadZero( mzero )
I prefer 3 (with 2 as a close second) since it is most like status quo.
-- Lennart
On 5 Nov, Simon Peyton-Jones wrote:
I don't like grabbing too many very generic names like zero, plus, fail
from the user (this is all in the Prelude, remember). I don't want
to grab 'raise' because we're going to want it for exceptions in Haskell
2. I havn't been able to think of
Simon Peyton-Jones wrote about Phil Wadler's idea:
| Good idea! So your suggestion is:
|
| class Monad m where
| ...return, =, as before...
|
| mfail :: String - m a
|
| class MonadPlus m where
| mplus :: m a - m a - m a
| mzero :: m a
I
The names `mzero' and `mfail' are horrible. I like Ralph's suggestion
to change `fail' to `raise' in the IO monad, and use `fail' for
`mfail'. If that doesn't work, try something else, but please
pick names that have a simple meaning in English (as with `return')
not monsters like `mzero'
There is no need to have both `mzero' and `mfail' in every monad.
Just have `mfail'. Leave `zero' and `plus' to MonadPlus. This should
make Eric partially happy. It also means one can simply write
instance Monad [] where
...return, =, as before...
mfail s = []
20 matches
Mail list logo