category-extras-0.44.2: src/Control/Applicative/Indexed.hs
-----------------------------------------------------------------------------
-- |
-- Module : Control.Applicative.Indexed
-- Copyright : (C) 2008 Edward Kmett
-- License : BSD-style (see the file LICENSE)
--
-- Maintainer : Edward Kmett <ekmett@gmail.com>
-- Stability : experimental
-- Portability : non-portable (rank-2 polymorphism)
--
----------------------------------------------------------------------------
module Control.Applicative.Indexed
( module Control.Applicative
, module Control.Functor.Pointed.Indexed
, IxApplicative(..)
) where
import Control.Applicative
import Control.Functor.Pointed.Indexed
class IxPointed m => IxApplicative m where
iap :: m i j (a -> b) -> m j k a -> m i k b
instance (Pointed m, Applicative m) => IxApplicative (LiftIx m) where
iap f m = LiftIx (lowerIx f <*> lowerIx m)
instance IxApplicative m => Applicative (LowerIx m i) where
pure = LowerIx . ireturn
f <*> m = LowerIx (liftIx f `iap` liftIx m)