Functor, Pointed, Applicative, Monad
As pointed out on StackOverflow, Functor, Pointed, Applicative and Monad all belong in a hierarchy thus:
class Functor f where
map :: (a -> b) -> f a -> f b
class Functor f => Pointed f where
pure :: a -> f a
class Pointed f => Applicative f where
(<*>) :: f (a -> b) -> f a -> f b
(*>) :: f a -> f b -> f b
(<*) :: f a -> f b -> f a
class Applicative m => Monad m where
(>>=) :: (m a) -> (a -> m b) -> m b
(>>) :: m a -> m b -> m b
return :: a -> m a
As well as eliminating much duplication (where every Applicative must also be given a Monad instance), this will make it easier to eliminate such duplication as [fmap,liftM,map,liftA], [(<*>),ap], and [concat,join].
fail does not belong in Monad; it only makes sense monadically as mzero.
Trac metadata
| Trac field | Value |
|---|---|
| Version | 6.12.3 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | libraries/base |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | gideon@accursoft.com |
| Operating system | |
| Architecture |