Skip to content

Joined-Up Classes

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.)

  1. 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
  1. 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
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information