-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Haskell 98 semigroupoids: Category sans id -- -- Provides a wide array of semigroupoids and operations for working with -- semigroupds. -- -- A Semigroupoid is a Category without the requirement of identity -- arrows for every object in the category. -- -- When working with comonads you often have the <*> -- portion of an Applicative, but not the pure. This -- was captured in Uustalu and Vene's "Essence of Dataflow Programming" -- in the form of the ComonadZip class in the days before -- Applicative. Apply provides a weaker invariant, but for the -- comonads used for data flow programming (found in the streams -- package), this invariant is preserved. Applicative function -- composition forms a semigroupoid. -- -- Similarly many structures are nearly a comonad, but not quite, for -- instance lists provide a reasonable extend operation in the -- form of tails, but do not always contain a value. -- -- Ideally the following relationships would hold: -- --
--   Traversable <---- Foldable <--- Functor ------> Alt ---------> Plus           Semigroupoid
--        |               |            |                              |                  |
--        v               v            v                              v                  v
--   Traversable1 <--- Foldable1     Apply --------> Applicative -> Alternative      Category
--                                     |               |              |                  |
--                                     v               v              v                  v
--                                   Bind ---------> Monad -------> MonadPlus          Arrow
--   
-- -- Apply, Bind, and Extend (not shown) give rise the Static, Kleisli and -- Cokleisli semigroupoids respectively. -- -- This lets us remove many of the restrictions from various monad -- transformers as in many cases the binding operation or -- <*> operation does not require them. -- -- Finally, to work with these weaker structures it is beneficial to have -- containers that can provide stronger guarantees about their contents, -- so versions of Traversable and Foldable that can be -- folded with just a Semigroup are added. @package semigroupoids @version 3.1 -- | Placeholders for missing instances of Traversable, until base catches -- up and adds them module Data.Traversable.Instances module Data.Functor.Extend class Functor w => Extend w where extended f = fmap f . duplicated duplicated = extended id duplicated :: Extend w => w a -> w (w a) extended :: Extend w => (w a -> b) -> w a -> w b instance [safe] Extend NonEmpty instance [safe] Extend w => Extend (IdentityT w) instance [safe] Extend Identity instance [safe] Extend Tree instance [safe] Extend Seq instance [safe] Semigroup m => Extend ((->) m) instance [safe] Extend ((,) e) instance [safe] Extend (Either a) instance [safe] Extend Maybe instance [safe] Extend [] -- | NB: The definitions exported through Data.Functor.Apply need to -- be included here because otherwise the instances for the transformers -- package have orphaned heads. module Data.Functor.Bind -- | The Functor class is used for types that can be mapped over. -- Instances of Functor should satisfy the following laws: -- --
--   fmap id  ==  id
--   fmap (f . g)  ==  fmap f . fmap g
--   
-- -- The instances of Functor for lists, Maybe and IO -- satisfy these laws. class Functor (f :: * -> *) fmap :: Functor f => (a -> b) -> f a -> f b (<$) :: Functor f => a -> f b -> f a -- | An infix synonym for fmap. (<$>) :: Functor f => (a -> b) -> f a -> f b -- | Replace the contents of a functor uniformly with a constant value. ($>) :: Functor f => f a -> b -> f b -- | A strong lax semi-monoidal endofunctor. This is equivalent to an -- Applicative without pure. -- -- Laws: -- --
--   associative composition: (.) <$> u <.> v <.> w = u <.> (v <.> w)
--   
class Functor f => Apply f where a .> b = const id <$> a <.> b a <. b = const <$> a <.> b (<.>) :: Apply f => f (a -> b) -> f a -> f b (.>) :: Apply f => f a -> f b -> f b (<.) :: Apply f => f a -> f b -> f a -- | A variant of <.> with the arguments reversed. (<..>) :: Apply w => w a -> w (a -> b) -> w b -- | Lift a binary function into a comonad with zipping liftF2 :: Apply w => (a -> b -> c) -> w a -> w b -> w c -- | Lift a ternary function into a comonad with zipping liftF3 :: Apply w => (a -> b -> c -> d) -> w a -> w b -> w c -> w d -- | Wrap an Applicative to be used as a member of Apply newtype WrappedApplicative f a WrapApplicative :: f a -> WrappedApplicative f a unwrapApplicative :: WrappedApplicative f a -> f a -- | Transform a Apply into an Applicative by adding a unit. newtype MaybeApply f a MaybeApply :: Either (f a) a -> MaybeApply f a runMaybeApply :: MaybeApply f a -> Either (f a) a -- | A Monad sans return. -- -- Minimal definition: Either join or >>- -- -- If defining both, then the following laws (the default definitions) -- must hold: -- --
--   join = (>>- id)
--   m >>- f = join (fmap f m)
--   
-- -- Laws: -- --
--   induced definition of <.>: f <.> x = f >>- (<$> x)
--   
-- -- Finally, there are two associativity conditions: -- --
--   associativity of (>>-):    (m >>- f) >>- g == m >>- (\x -> f x >>- g)
--   associativity of join:     join . join = join . fmap join
--   
-- -- These can both be seen as special cases of the constraint that -- --
--   associativity of (->-): (f ->- g) ->- h = f ->- (g ->- h)
--   
class Apply m => Bind m where m >>- f = join (fmap f m) join = (>>- id) (>>-) :: Bind m => m a -> (a -> m b) -> m b join :: Bind m => m (m a) -> m a (-<<) :: Bind m => (a -> m b) -> m a -> m b (-<-) :: Bind m => (b -> m c) -> (a -> m b) -> a -> m c (->-) :: Bind m => (a -> m b) -> (b -> m c) -> a -> m c apDefault :: Bind f => f (a -> b) -> f a -> f b returning :: Functor f => f a -> (a -> b) -> f b instance Bind Tree instance Bind Seq instance Bind IntMap instance Ord k => Bind (Map k) instance Bind (ContT r m) instance (Bind m, Semigroup w) => Bind (RWST r w s m) instance (Bind m, Semigroup w) => Bind (RWST r w s m) instance Bind m => Bind (StateT s m) instance Bind m => Bind (StateT s m) instance (Bind m, Semigroup w) => Bind (WriterT w m) instance (Bind m, Semigroup w) => Bind (WriterT w m) instance Bind m => Bind (ReaderT e m) instance (Bind m, Monad m) => Bind (ErrorT e m) instance (Bind m, Monad m) => Bind (ListT m) instance (Bind m, Monad m) => Bind (MaybeT m) instance Monad m => Bind (WrappedMonad m) instance Bind m => Bind (IdentityT m) instance Bind Identity instance Bind Option instance Bind Maybe instance Bind IO instance Bind NonEmpty instance Bind [] instance Bind ((->) m) instance (Bind f, Bind g) => Bind (Product f g) instance Bind (Either a) instance Semigroup m => Bind ((,) m) instance Apply (Cokleisli w a) instance Comonad f => Comonad (MaybeApply f) instance Extend f => Extend (MaybeApply f) instance Apply f => Applicative (MaybeApply f) instance Apply f => Apply (MaybeApply f) instance Functor f => Functor (MaybeApply f) instance Alternative f => Alternative (WrappedApplicative f) instance Applicative f => Applicative (WrappedApplicative f) instance Applicative f => Apply (WrappedApplicative f) instance Functor f => Functor (WrappedApplicative f) instance Apply (ContT r m) instance (Bind m, Semigroup w) => Apply (RWST r w s m) instance (Bind m, Semigroup w) => Apply (RWST r w s m) instance Bind m => Apply (StateT s m) instance Bind m => Apply (StateT s m) instance (Apply m, Semigroup w) => Apply (WriterT w m) instance (Apply m, Semigroup w) => Apply (WriterT w m) instance Apply m => Apply (ListT m) instance Apply m => Apply (ReaderT e m) instance (Bind m, Monad m) => Apply (ErrorT e m) instance (Bind m, Monad m) => Apply (MaybeT m) instance Apply Tree instance Apply Seq instance Apply IntMap instance Ord k => Apply (Map k) instance Arrow a => Apply (WrappedArrow a b) instance Monad m => Apply (WrappedMonad m) instance Apply w => Apply (IdentityT w) instance Apply Identity instance Apply Option instance Apply Maybe instance Apply IO instance Apply [] instance Apply ZipList instance Apply ((->) m) instance Semigroup m => Apply (Const m) instance Apply (Either a) instance Apply NonEmpty instance Semigroup m => Apply ((,) m) instance (Apply f, Apply g) => Apply (Product f g) instance (Apply f, Apply g) => Apply (Compose f g) module Data.Functor.Bind.Trans -- | A subset of monad transformers can transform any Bind as well. class MonadTrans t => BindTrans t liftB :: (BindTrans t, Bind b) => b a -> t b a instance BindTrans (ContT r) instance (Semigroup w, Monoid w) => BindTrans (RWST r w s) instance (Semigroup w, Monoid w) => BindTrans (RWST r w s) instance BindTrans (StateT s) instance BindTrans (StateT s) instance (Semigroup w, Monoid w) => BindTrans (WriterT w) instance (Semigroup w, Monoid w) => BindTrans (WriterT w) instance BindTrans (ReaderT e) instance BindTrans IdentityT -- | A semigroupoid satisfies all of the requirements to be a Category -- except for the existence of identity arrows. module Data.Semigroupoid -- | Category sans id class Semigroupoid c o :: Semigroupoid c => c j k -> c i j -> c i k newtype WrappedCategory k a b WrapCategory :: k a b -> WrappedCategory k a b unwrapCategory :: WrappedCategory k a b -> k a b newtype Semi m a b Semi :: m -> Semi m a b getSemi :: Semi m a b -> m instance Monoid m => Category (Semi m) instance Semigroup m => Semigroupoid (Semi m) instance Category k => Category (WrappedCategory k) instance Category k => Semigroupoid (WrappedCategory k) instance Semigroupoid Op instance Extend w => Semigroupoid (Cokleisli w) instance Bind m => Semigroupoid (Kleisli m) instance Semigroupoid (,) instance Semigroupoid (->) -- | A semigroupoid satisfies all of the requirements to be a Category -- except for the existence of identity arrows. module Data.Semigroupoid.Dual newtype Dual k a b Dual :: k b a -> Dual k a b getDual :: Dual k a b -> k b a instance Category k => Category (Dual k) instance Semigroupoid k => Semigroupoid (Dual k) module Data.Functor.Apply -- | The Functor class is used for types that can be mapped over. -- Instances of Functor should satisfy the following laws: -- --
--   fmap id  ==  id
--   fmap (f . g)  ==  fmap f . fmap g
--   
-- -- The instances of Functor for lists, Maybe and IO -- satisfy these laws. class Functor (f :: * -> *) fmap :: Functor f => (a -> b) -> f a -> f b (<$) :: Functor f => a -> f b -> f a -- | An infix synonym for fmap. (<$>) :: Functor f => (a -> b) -> f a -> f b -- | Replace the contents of a functor uniformly with a constant value. ($>) :: Functor f => f a -> b -> f b -- | A strong lax semi-monoidal endofunctor. This is equivalent to an -- Applicative without pure. -- -- Laws: -- --
--   associative composition: (.) <$> u <.> v <.> w = u <.> (v <.> w)
--   
class Functor f => Apply f where a .> b = const id <$> a <.> b a <. b = const <$> a <.> b (<.>) :: Apply f => f (a -> b) -> f a -> f b (.>) :: Apply f => f a -> f b -> f b (<.) :: Apply f => f a -> f b -> f a -- | A variant of <.> with the arguments reversed. (<..>) :: Apply w => w a -> w (a -> b) -> w b -- | Lift a binary function into a comonad with zipping liftF2 :: Apply w => (a -> b -> c) -> w a -> w b -> w c -- | Lift a ternary function into a comonad with zipping liftF3 :: Apply w => (a -> b -> c -> d) -> w a -> w b -> w c -> w d -- | Wrap an Applicative to be used as a member of Apply newtype WrappedApplicative f a WrapApplicative :: f a -> WrappedApplicative f a unwrapApplicative :: WrappedApplicative f a -> f a -- | Transform a Apply into an Applicative by adding a unit. newtype MaybeApply f a MaybeApply :: Either (f a) a -> MaybeApply f a runMaybeApply :: MaybeApply f a -> Either (f a) a module Data.Semigroup.Foldable class Foldable t => Foldable1 t where foldMap1 f = maybe (error "foldMap1") id . getOption . foldMap (Option . Just . f) fold1 = foldMap1 id fold1 :: (Foldable1 t, Semigroup m) => t m -> m foldMap1 :: (Foldable1 t, Semigroup m) => (a -> m) -> t a -> m traverse1_ :: (Foldable1 t, Apply f) => (a -> f b) -> t a -> f () for1_ :: (Foldable1 t, Apply f) => t a -> (a -> f b) -> f () sequenceA1_ :: (Foldable1 t, Apply f) => t (f a) -> f () -- | Usable default for foldMap, but only if you define foldMap1 yourself foldMapDefault1 :: (Foldable1 t, Monoid m) => (a -> m) -> t a -> m instance Functor f => Functor (Act f) instance Apply f => Semigroup (Act f a) instance Foldable1 NonEmpty instance (Foldable1 f, Foldable1 g) => Foldable1 (Product f g) instance (Foldable1 f, Foldable1 g) => Foldable1 (Compose f g) instance Foldable1 m => Foldable1 (IdentityT m) instance Foldable1 Identity instance Foldable1 Tree module Data.Semigroup.Traversable class (Foldable1 t, Traversable t) => Traversable1 t where sequence1 = traverse1 id traverse1 f = sequence1 . fmap f traverse1 :: (Traversable1 t, Apply f) => (a -> f b) -> t a -> f (t b) sequence1 :: (Traversable1 t, Apply f) => t (f b) -> f (t b) foldMap1Default :: (Traversable1 f, Semigroup m) => (a -> m) -> f a -> m instance Traversable1 NonEmpty instance Traversable1 Tree instance (Traversable1 f, Traversable1 g) => Traversable1 (Product f g) instance (Traversable1 f, Traversable1 g) => Traversable1 (Compose f g) instance Traversable1 f => Traversable1 (IdentityT f) instance Traversable1 Identity module Data.Functor.Alt -- | Laws: -- --
--   <!> is associative:             (a <!> b) <!> c = a <!> (b <!> c)
--   <$> left-distributes over <!>:  f <$> (a <!> b) = (f <$> a) <!> (f <$> b)
--   
-- -- If extended to an Alternative then <!> should -- equal <|>. -- -- Ideally, an instance of Alt also satisfies the "left -- distributon" law of MonadPlus with respect to .: -- --
--   <.> right-distributes over <!>: (a <!> b) <.> c = (a <.> c) <!> (b <.> c)
--   
-- -- But Maybe, IO, Either a, -- ErrorT e m, and STM satisfy the alternative -- "left catch" law instead: -- --
--   pure a <!> b = pure a
--   
-- -- However, this variation cannot be stated purely in terms of the -- dependencies of Alt. -- -- When and if MonadPlus is successfully refactored, this class should -- also be refactored to remove these instances. -- -- The right distributive law should extend in the cases where the a -- Bind or Monad is provided to yield variations of the -- right distributive law: -- --
--   (m <!> n) >>- f = (m >>- f) <!> (m >>- f)
--   (m <!> n) >>= f = (m >>= f) <!> (m >>= f)
--   
class Functor f => Alt f where some v = some_v where many_v = some_v pure [] some_v = (:) <$> v <*> many_v many v = many_v where many_v = some_v pure [] some_v = (:) <$> v <*> many_v () :: Alt f => f a -> f a -> f a some :: (Alt f, Applicative f) => f a -> f [a] many :: (Alt f, Applicative f) => f a -> f [a] instance [safe] Alt f => Alt (RWST r w s f) instance [safe] Alt f => Alt (RWST r w s f) instance [safe] Alt f => Alt (WriterT w f) instance [safe] Alt f => Alt (WriterT w f) instance [safe] Alt f => Alt (StateT e f) instance [safe] Alt f => Alt (StateT e f) instance [safe] Apply f => Alt (ListT f) instance [safe] (Bind f, Monad f) => Alt (ErrorT e f) instance [safe] (Bind f, Monad f) => Alt (MaybeT f) instance [safe] Alt f => Alt (ReaderT e f) instance [safe] Alt f => Alt (IdentityT f) instance [safe] Alternative f => Alt (WrappedApplicative f) instance [safe] Alt NonEmpty instance [safe] Alt Seq instance [safe] Alt IntMap instance [safe] Ord k => Alt (Map k) instance [safe] ArrowPlus a => Alt (WrappedArrow a b) instance [safe] MonadPlus m => Alt (WrappedMonad m) instance [safe] Alt Option instance [safe] Alt Maybe instance [safe] Alt [] instance [safe] Alt IO instance [safe] Alt (Either a) module Data.Functor.Plus -- | Laws: -- --
--   zero <!> m = m
--   m <!> zero = m
--   
-- -- If extended to an Alternative then zero should equal -- empty. class Alt f => Plus f zero :: Plus f => f a instance [safe] Plus f => Plus (RWST r w s f) instance [safe] Plus f => Plus (RWST r w s f) instance [safe] Plus f => Plus (WriterT w f) instance [safe] Plus f => Plus (WriterT w f) instance [safe] Plus f => Plus (StateT e f) instance [safe] Plus f => Plus (StateT e f) instance [safe] (Apply f, Applicative f) => Plus (ListT f) instance [safe] (Bind f, Monad f, Error e) => Plus (ErrorT e f) instance [safe] (Bind f, Monad f) => Plus (MaybeT f) instance [safe] Plus f => Plus (ReaderT e f) instance [safe] Plus f => Plus (IdentityT f) instance [safe] Alternative f => Plus (WrappedApplicative f) instance [safe] Plus Seq instance [safe] Plus IntMap instance [safe] Ord k => Plus (Map k) instance [safe] ArrowPlus a => Plus (WrappedArrow a b) instance [safe] MonadPlus m => Plus (WrappedMonad m) instance [safe] Plus Option instance [safe] Plus Maybe instance [safe] Plus [] instance [safe] Plus IO module Data.Semigroupoid.Static newtype Static f a b Static :: f (a -> b) -> Static f a b runStatic :: Static f a b -> f (a -> b) instance Applicative f => ArrowChoice (Static f) instance Alternative f => ArrowPlus (Static f) instance Alternative f => ArrowZero (Static f) instance Applicative f => Arrow (Static f) instance Applicative f => Category (Static f) instance Apply f => Semigroupoid (Static f) instance (Comonad f, Monoid a) => Comonad (Static f a) instance (Extend f, Semigroup a) => Extend (Static f a) instance Applicative f => Applicative (Static f a) instance Plus f => Plus (Static f a) instance Alt f => Alt (Static f a) instance Apply f => Apply (Static f a) instance Functor f => Functor (Static f a)