Joined-Up Classes
Currently the Monad class is not a subclass of Functor. It should be.
Proposal:
- Add this:
class (Functor f) => Idiom f where -- or Applicative
return :: a -> f a
ap :: f (a -> b) -> f a -> f b
(>>) :: f a -> f b -> f b
fa >> fb = ap (fmap (const id) fa) fb
(See also Control.Applicative in GHC HEAD.)
- Replace existing Monad class with this:
class (Idiom m) => Monad m where
(>>=) :: m a -> (a -> m b) -> m b
fail :: String -> m a
fail = error
- Remove existing "ap", generalise and remove redundant Prelude functions as appropriate.
Trac metadata
| Trac field | Value |
|---|---|
| Version | |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Proposal |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture |