Ticket #113 (new modification)
Opened 7 years ago
Joined-Up Classes
| Reported by: | ashley@… | Owned by: | none |
|---|---|---|---|
| Milestone: | Keywords: | ||
| Cc: | Section: | ||
| State: |
Description
Currently the Monad class is not a subclass of Functor. It should be.
Proposal:
1. 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.)
2. 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
3. Remove existing "ap", generalise and remove redundant Prelude functions as appropriate.
Note: See
TracTickets for help on using
tickets.
