#4481: Functor, Pointed, Applicative, Monad
---------------------------------+------------------------------------------
    Reporter:  gidyn             |       Owner:                
        Type:  proposal          |      Status:  new           
    Priority:  normal            |   Component:  libraries/base
     Version:  6.12.3            |    Keywords:                
    Testcase:                    |   Blockedby:                
          Os:  Unknown/Multiple  |    Blocking:                
Architecture:  Unknown/Multiple  |     Failure:  None/Unknown  
---------------------------------+------------------------------------------
 As pointed out on [http://stackoverflow.com/questions/1634911/can-liftm-
 differ-from-lifta 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.

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/4481>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs

Reply via email to