We're nearly done with Haskell 98.
* In my last progress report I said:
However a couple of other similar proposals have been made
- add succ and pred to class Enum
- add atan2 to class RealFloat
I've had no complaints so I consider this done.
* Still no decision about the default default. I'm minded to
try out the change myself and see how many times it's used
in the nofib suite. I think the main choices are
(Int, Double)
(Integer, Double)
* I've had some out-of-band discussions about naming for the monad
operations. The outcome I propose is below; it's more uniform than
before.
I'm inclined to delete kleisli (was applyM). It won't mean much to
most people.
It's unfortunate that there is both filterM and mfilter; but that's what
the naming convention says.
Many thanks to Phil, Colin, Olaf, Erik, Johan for help with these names.
I'll get a draft report out next week.
Simon
Naming convention for monadic/functorial things
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
** Postfix `M' always stands for a function in the Kleisli category:
m is added to function results (modulo currying) and nowhere else.
** Postifx `_' changes result type from (m a) to (m ()).
** Prefix `m' generalises an existing function over lists to monads
** Prefix 'f' generalises an existing function over lists to functors
In the Prelude
~~~~~~~~~~~~~~~
class Functor f where
fmap :: (a -> b) -> f a -> f b
class Monad m where
return :: a -> m a
(>>=) :: m a -> (a -> m b) -> m b
(>>) :: m a -> m b -> m b
fail :: String -> m a
sequence :: Monad m => [m a] -> m [a]
-- Was accumulate
sequence_ :: Monad m => [m a] -> m ()
-- Was sequence
mapM :: Monad m => (a -> m b) -> [a] -> m [b]
mapM_ :: Monad m => (a -> m b) -> [a] -> m ()
In the Monad library
~~~~~~~~~~~~~~~~~~~~~
?? kleisli :: Monad m => (a -> m b) -> m a -> m b
-- was appplyM
filterM :: Monad m => (a -> m Bool) -> [a] -> m [a]
join :: (Monad m) => m (m a) -> m a
mapAndUnzipM :: (Monad m) => (a -> m (b,c)) -> [a] -> m ([b], [c])
zipWithM :: (Monad m) => (a -> b -> m c) -> [a] -> [b] -> m [c]
zipWithM_ :: (Monad m) => (a -> b -> m c) -> [a] -> [b] -> m ()
foldM :: (Monad m) => (a -> b -> m a) -> a -> [b] -> m a
foldM_ :: (Monad m) => (a -> b -> m a) -> a -> [b] -> m ()
class Monad m => MonadPlus m where
mzero :: m a
mplus :: m a -> m a -> m a
msum :: MonadPlus m => [m a] -> m a
-- was concatM
mfilter :: MonadPlus m => (a -> Bool) -> m a -> m a
guard :: MonadPlus m => Bool -> m ()