Opened 13 years ago

Closed 4 years ago

Last modified 4 years ago

#113 closed modification (superseded)

Joined-Up Classes

Reported by: ashley@… Owned by: none
Priority: normal Milestone:
Version: Keywords:
Cc: David Luposchainsky Meta Owner:
State: Section: Predefined Types/Classes
Related Tickets: #146

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

  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
    
  2. Remove existing "ap", generalise and remove redundant Prelude functions as appropriate.

Change History (4)

comment:1 Changed 4 years ago by Herbert Valerio Riedel

Milestone:

moving non-milestoned many year old legacy tickets out of the way

comment:2 Changed 4 years ago by Herbert Valerio Riedel

Priority: majornormal

Set default priority (as this confuses Trac otherwise)

comment:3 Changed 4 years ago by Herbert Valerio Riedel

Cc: David Luposchainsky added
Resolution: superseded
Section: Predefined Types/Classes
Status: newclosed

This is effectively superseded by #146 (AMP)

comment:4 Changed 4 years ago by Herbert Valerio Riedel

Note: See TracTickets for help on using tickets.