Lined-up Haskell types

Got more to add? Submit a GitHub issue or talk to me on Twitter.

Function application

($)      ::                                     (a ->   b) ->   a ->      b
(<$>)    ::  Functor     f                 =>   (a ->   b) -> f a -> f    b
(<*>)    ::  Applicative f                 => f (a ->   b) -> f a -> f    b
(=<<)    ::  Monad       f                 =>   (a -> f b) -> f a -> f    b
mapM     :: (Monad       f, Traversable t) =>   (a -> f b) -> t a -> f (t b)
traverse :: (Applicative f, Traversable t) =>   (a -> f b) -> t a -> f (t b)
foldMap  :: (Monoid      b, Traversable t) =>   (a ->   b) -> t a ->      b

Applicative lifting

pure   :: Applicative f =>  a                 -> f a
liftA  :: Applicative f => (a -> b)           -> f a -> f b
liftA2 :: Applicative f => (a -> b -> c)      -> f a -> f b -> f c
liftA3 :: Applicative f => (a -> b -> c -> d) -> f a -> f b -> f c -> f d

Function composition

(.)   ::            (b ->   c) -> (a ->   b) -> a ->   c
(<=<) :: Monad m => (b -> m c) -> (a -> m b) -> a -> m c

Filtering

filter  ::                (a ->   Bool) ->  [a] ->   [a]
filterM :: Monad     m => (a -> m Bool) ->  [a] -> m [a]
mfilter :: MonadPlus m => (a ->   Bool) -> m a  -> m  a

Monoidal folding

fold    :: (Monoid m, Foldable t) => t m   -> m
mconcat ::  Monoid m              =>  [m]  -> m
concat  ::                           [[a]] -> [a]

Discarding one of two values

const ::                    a ->   b ->   a
(<$)  :: Functor     f =>   a -> f b -> f a
(<*)  :: Applicative f => f a -> f b -> f a
($>)  :: Functor     f => f a ->   b -> f b
(*>)  :: Applicative f => f a -> f b -> f b
(>>)  :: Monad       f => f a -> f b -> f b

Restructuring

sequenceA :: (Applicative f, Traversable t) => t (f a) -> f (t a)
sequence  :: (Monad       f, Traversable t) => t (f a) -> f (t a)
join      ::  Monad       f                 => f (f a) -> f    a

Lifting

id     ::                                     a ->     a
pure   ::  Applicative f                =>    a ->   f a
return ::  Monad       m                =>    a ->   m a
liftIO ::  MonadIO     m                => IO a ->   m a
lift   :: (Monad       m, MonadTrans t) => m  a -> t m a

Running transformers

runIdentityT :: IdentityT m a -> m        a
runListT     :: ListT     m a -> m       [a]
runMaybeT    :: MaybeT    m a -> m (Maybe a)

The monoid in Monad

mappend :: Monoid m => m -> m    -> m
join    :: Monad  m => m   (m a) -> m a

mempty  :: Monoid m =>      m
return  :: Monad  m => a -> m a