-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | Kan extensions, Kan lifts, the Yoneda lemma, and (co)density (co)monads
--   
--   Kan extensions, Kan lifts, various forms of the Yoneda lemma, and
--   (co)density (co)monads.
@package kan-extensions
@version 5.2.7


-- | The co-Yoneda lemma for presheafs states that <tt>f</tt> is naturally
--   isomorphic to <tt><a>Coyoneda</a> f</tt>.
module Data.Functor.Contravariant.Coyoneda

-- | A <a>Contravariant</a> functor (aka presheaf) suitable for Yoneda
--   reduction.
--   
--   <a>http://ncatlab.org/nlab/show/Yoneda+reduction</a>
data Coyoneda (f :: Type -> Type) a
[Coyoneda] :: forall a b (f :: Type -> Type). (a -> b) -> f b -> Coyoneda f a

-- | Coyoneda "expansion" of a presheaf
--   
--   <pre>
--   <a>liftCoyoneda</a> . <a>lowerCoyoneda</a> ≡ <a>id</a>
--   <a>lowerCoyoneda</a> . <a>liftCoyoneda</a> ≡ <a>id</a>
--   </pre>
liftCoyoneda :: f a -> Coyoneda f a

-- | Coyoneda reduction on a presheaf
lowerCoyoneda :: Contravariant f => Coyoneda f a -> f a

-- | Lift a natural transformation from <tt>f</tt> to <tt>g</tt> to a
--   natural transformation from <tt>Coyoneda f</tt> to <tt>Coyoneda
--   g</tt>.
hoistCoyoneda :: (forall a. () => f a -> g a) -> Coyoneda f b -> Coyoneda g b
instance Data.Functor.Contravariant.Adjunction.Adjunction f g => Data.Functor.Contravariant.Adjunction.Adjunction (Data.Functor.Contravariant.Coyoneda.Coyoneda f) (Data.Functor.Contravariant.Coyoneda.Coyoneda g)
instance Data.Functor.Contravariant.Contravariant (Data.Functor.Contravariant.Coyoneda.Coyoneda f)
instance Data.Functor.Contravariant.Rep.Representable f => Data.Functor.Contravariant.Rep.Representable (Data.Functor.Contravariant.Coyoneda.Coyoneda f)


-- | The Day convolution of two contravariant functors is a contravariant
--   functor.
--   
--   <a>http://ncatlab.org/nlab/show/Day+convolution</a>
module Data.Functor.Contravariant.Day

-- | The Day convolution of two contravariant functors.
data Day (f :: Type -> Type) (g :: Type -> Type) a
Day :: f b -> g c -> (a -> (b, c)) -> Day (f :: Type -> Type) (g :: Type -> Type) a

-- | Construct the Day convolution
--   
--   <pre>
--   <a>day1</a> (<a>day</a> f g) = f
--   <a>day2</a> (<a>day</a> f g) = g
--   </pre>
day :: f a -> g b -> Day f g (a, b)

-- | Break apart the Day convolution of two contravariant functors.
runDay :: (Contravariant f, Contravariant g) => Day f g a -> (f a, g a)

-- | Day convolution provides a monoidal product. The associativity of this
--   monoid is witnessed by <a>assoc</a> and <a>disassoc</a>.
--   
--   <pre>
--   <a>assoc</a> . <a>disassoc</a> = <a>id</a>
--   <a>disassoc</a> . <a>assoc</a> = <a>id</a>
--   <a>contramap</a> f <a>.</a> <a>assoc</a> = <a>assoc</a> <a>.</a> <a>contramap</a> f
--   </pre>
assoc :: forall (f :: Type -> Type) (g :: Type -> Type) (h :: Type -> Type) a. Day f (Day g h) a -> Day (Day f g) h a

-- | Day convolution provides a monoidal product. The associativity of this
--   monoid is witnessed by <a>assoc</a> and <a>disassoc</a>.
--   
--   <pre>
--   <a>assoc</a> . <a>disassoc</a> = <a>id</a>
--   <a>disassoc</a> . <a>assoc</a> = <a>id</a>
--   <a>contramap</a> f <a>.</a> <a>disassoc</a> = <a>disassoc</a> <a>.</a> <a>contramap</a> f
--   </pre>
disassoc :: forall (f :: Type -> Type) (g :: Type -> Type) (h :: Type -> Type) a. Day (Day f g) h a -> Day f (Day g h) a

-- | The monoid for Day convolution <i>in Haskell</i> is symmetric.
--   
--   <pre>
--   <a>contramap</a> f <a>.</a> <a>swapped</a> = <a>swapped</a> <a>.</a> <a>contramap</a> f
--   </pre>
swapped :: forall (f :: Type -> Type) (g :: Type -> Type) a. Day f g a -> Day g f a

-- | Proxy serves as the unit of Day convolution.
--   
--   <pre>
--   <a>day1</a> <a>.</a> <a>intro1</a> = <a>id</a>
--   <a>contramap</a> f <a>.</a> <a>intro1</a> = <a>intro1</a> <a>.</a> <a>contramap</a> f
--   </pre>
intro1 :: f a -> Day (Proxy :: Type -> Type) f a

-- | Proxy serves as the unit of Day convolution.
--   
--   <pre>
--   <a>day2</a> <a>.</a> <a>intro2</a> = <a>id</a>
--   <a>contramap</a> f <a>.</a> <a>intro2</a> = <a>intro2</a> <a>.</a> <a>contramap</a> f
--   </pre>
intro2 :: f a -> Day f (Proxy :: Type -> Type) a

-- | In Haskell we can do general purpose elimination, but in a more
--   general setting it is only possible to eliminate the unit.
--   
--   <pre>
--   <a>day1</a> <a>.</a> <a>intro1</a> = <a>id</a>
--   <a>day1</a> = <a>fst</a> <a>.</a> <a>runDay</a>
--   <a>contramap</a> f <a>.</a> <a>day1</a> = <a>day1</a> <a>.</a> <a>contramap</a> f
--   </pre>
day1 :: forall f (g :: Type -> Type) a. Contravariant f => Day f g a -> f a

-- | In Haskell we can do general purpose elimination, but in a more
--   general setting it is only possible to eliminate the unit. <tt>
--   <a>day2</a> <a>.</a> <a>intro2</a> = <a>id</a> <a>day2</a> =
--   <a>snd</a> <a>.</a> <a>runDay</a> <a>contramap</a> f <a>.</a>
--   <a>day2</a> = <a>day2</a> <a>.</a> <a>contramap</a> f </tt>
day2 :: forall g (f :: Type -> Type) a. Contravariant g => Day f g a -> g a

-- | Diagonalize the Day convolution:
--   
--   <pre>
--   <a>day1</a> <a>.</a> <a>diag</a> = <a>id</a>
--   <a>day2</a> <a>.</a> <a>diag</a> = <a>id</a>
--   <a>runDay</a> <a>.</a> <a>diag</a> = a -&gt; (a,a)
--   <a>contramap</a> f . <a>diag</a> = <a>diag</a> . <a>contramap</a> f
--   </pre>
diag :: f a -> Day f f a

-- | Apply a natural transformation to the left-hand side of a Day
--   convolution.
--   
--   This respects the naturality of the natural transformation you
--   supplied:
--   
--   <pre>
--   <a>contramap</a> f <a>.</a> <a>trans1</a> fg = <a>trans1</a> fg <a>.</a> <a>contramap</a> f
--   </pre>
trans1 :: forall f g (h :: Type -> Type) a. (forall x. () => f x -> g x) -> Day f h a -> Day g h a

-- | Apply a natural transformation to the right-hand side of a Day
--   convolution.
--   
--   This respects the naturality of the natural transformation you
--   supplied:
--   
--   <pre>
--   <a>contramap</a> f <a>.</a> <a>trans2</a> fg = <a>trans2</a> fg <a>.</a> <a>contramap</a> f
--   </pre>
trans2 :: forall g h (f :: Type -> Type) a. (forall x. () => g x -> h x) -> Day f g a -> Day f h a
instance (Data.Functor.Contravariant.Adjunction.Adjunction f u, Data.Functor.Contravariant.Adjunction.Adjunction f' u') => Data.Functor.Contravariant.Adjunction.Adjunction (Data.Functor.Contravariant.Day.Day f f') (Data.Functor.Contravariant.Day.Day u u')
instance Data.Functor.Contravariant.Contravariant (Data.Functor.Contravariant.Day.Day f g)
instance (Data.Functor.Contravariant.Divisible.Divisible f, Data.Functor.Contravariant.Divisible.Divisible g) => Data.Functor.Contravariant.Divisible.Divisible (Data.Functor.Contravariant.Day.Day f g)
instance (Data.Functor.Contravariant.Rep.Representable f, Data.Functor.Contravariant.Rep.Representable g) => Data.Functor.Contravariant.Rep.Representable (Data.Functor.Contravariant.Day.Day f g)


module Data.Functor.Contravariant.Yoneda

-- | Yoneda embedding for a presheaf
newtype Yoneda (f :: Type -> Type) a
Yoneda :: (forall r. () => (r -> a) -> f r) -> Yoneda (f :: Type -> Type) a
[runYoneda] :: Yoneda (f :: Type -> Type) a -> forall r. () => (r -> a) -> f r

-- | <pre>
--   <a>liftYoneda</a> . <a>lowerYoneda</a> ≡ <a>id</a>
--   <a>lowerYoneda</a> . <a>liftYoneda</a> ≡ <a>id</a>
--   </pre>
liftYoneda :: Contravariant f => f a -> Yoneda f a
lowerYoneda :: Yoneda f a -> f a
instance Data.Functor.Contravariant.Adjunction.Adjunction f g => Data.Functor.Contravariant.Adjunction.Adjunction (Data.Functor.Contravariant.Yoneda.Yoneda f) (Data.Functor.Contravariant.Yoneda.Yoneda g)
instance Data.Functor.Contravariant.Contravariant (Data.Functor.Contravariant.Yoneda.Yoneda f)
instance Data.Functor.Contravariant.Rep.Representable f => Data.Functor.Contravariant.Rep.Representable (Data.Functor.Contravariant.Yoneda.Yoneda f)


-- | Eitan Chatav first introduced me to this construction
--   
--   The Day convolution of two covariant functors is a covariant functor.
--   
--   Day convolution is usually defined in terms of contravariant functors,
--   however, it just needs a monoidal category, and Hask^op is also
--   monoidal.
--   
--   Day convolution can be used to nicely describe monoidal functors as
--   monoid objects w.r.t this product.
--   
--   <a>http://ncatlab.org/nlab/show/Day+convolution</a>
module Data.Functor.Day

-- | The Day convolution of two covariant functors.
data Day (f :: Type -> Type) (g :: Type -> Type) a
Day :: f b -> g c -> (b -> c -> a) -> Day (f :: Type -> Type) (g :: Type -> Type) a

-- | Construct the Day convolution
day :: f (a -> b) -> g a -> Day f g b

-- | Collapse via a monoidal functor.
--   
--   <pre>
--   <a>dap</a> (<a>day</a> f g) = f <a>&lt;*&gt;</a> g
--   </pre>
dap :: Applicative f => Day f f a -> f a

-- | Day convolution provides a monoidal product. The associativity of this
--   monoid is witnessed by <a>assoc</a> and <a>disassoc</a>.
--   
--   <pre>
--   <a>assoc</a> . <a>disassoc</a> = <a>id</a>
--   <a>disassoc</a> . <a>assoc</a> = <a>id</a>
--   <a>fmap</a> f <a>.</a> <a>assoc</a> = <a>assoc</a> <a>.</a> <a>fmap</a> f
--   </pre>
assoc :: forall (f :: Type -> Type) (g :: Type -> Type) (h :: Type -> Type) a. Day f (Day g h) a -> Day (Day f g) h a

-- | Day convolution provides a monoidal product. The associativity of this
--   monoid is witnessed by <a>assoc</a> and <a>disassoc</a>.
--   
--   <pre>
--   <a>assoc</a> . <a>disassoc</a> = <a>id</a>
--   <a>disassoc</a> . <a>assoc</a> = <a>id</a>
--   <a>fmap</a> f <a>.</a> <a>disassoc</a> = <a>disassoc</a> <a>.</a> <a>fmap</a> f
--   </pre>
disassoc :: forall (f :: Type -> Type) (g :: Type -> Type) (h :: Type -> Type) a. Day (Day f g) h a -> Day f (Day g h) a

-- | The monoid for <a>Day</a> convolution on the cartesian monoidal
--   structure is symmetric.
--   
--   <pre>
--   <a>fmap</a> f <a>.</a> <a>swapped</a> = <a>swapped</a> <a>.</a> <a>fmap</a> f
--   </pre>
swapped :: forall (f :: Type -> Type) (g :: Type -> Type) a. Day f g a -> Day g f a

-- | <a>Identity</a> is the unit of <a>Day</a> convolution
--   
--   <pre>
--   <a>intro1</a> <a>.</a> <a>elim1</a> = <a>id</a>
--   <a>elim1</a> <a>.</a> <a>intro1</a> = <a>id</a>
--   </pre>
intro1 :: f a -> Day Identity f a

-- | <a>Identity</a> is the unit of <a>Day</a> convolution
--   
--   <pre>
--   <a>intro2</a> <a>.</a> <a>elim2</a> = <a>id</a>
--   <a>elim2</a> <a>.</a> <a>intro2</a> = <a>id</a>
--   </pre>
intro2 :: f a -> Day f Identity a

-- | <a>Identity</a> is the unit of <a>Day</a> convolution
--   
--   <pre>
--   <a>intro1</a> <a>.</a> <a>elim1</a> = <a>id</a>
--   <a>elim1</a> <a>.</a> <a>intro1</a> = <a>id</a>
--   </pre>
elim1 :: Functor f => Day Identity f a -> f a

-- | <a>Identity</a> is the unit of <a>Day</a> convolution
--   
--   <pre>
--   <a>intro2</a> <a>.</a> <a>elim2</a> = <a>id</a>
--   <a>elim2</a> <a>.</a> <a>intro2</a> = <a>id</a>
--   </pre>
elim2 :: Functor f => Day f Identity a -> f a

-- | Apply a natural transformation to the left-hand side of a Day
--   convolution.
--   
--   This respects the naturality of the natural transformation you
--   supplied:
--   
--   <pre>
--   <a>fmap</a> f <a>.</a> <a>trans1</a> fg = <a>trans1</a> fg <a>.</a> <a>fmap</a> f
--   </pre>
trans1 :: forall f g (h :: Type -> Type) a. (forall x. () => f x -> g x) -> Day f h a -> Day g h a

-- | Apply a natural transformation to the right-hand side of a Day
--   convolution.
--   
--   This respects the naturality of the natural transformation you
--   supplied:
--   
--   <pre>
--   <a>fmap</a> f <a>.</a> <a>trans2</a> fg = <a>trans2</a> fg <a>.</a> <a>fmap</a> f
--   </pre>
trans2 :: forall g h (f :: Type -> Type) a. (forall x. () => g x -> h x) -> Day f g a -> Day f h a
cayley :: forall (f :: Type -> Type) (p :: Type -> Type -> Type) (g :: Type -> Type) (q :: Type -> Type -> Type) a b. Procompose (Cayley f p) (Cayley g q) a b -> Cayley (Day f g) (Procompose p q) a b

-- | Proposition 4.1 from Pastro and Street
dayley :: forall (p :: Type -> Type -> Type) (f :: Type -> Type) (g :: Type -> Type) a b. Category p => Procompose (Cayley f p) (Cayley g p) a b -> Cayley (Day f g) p a b
instance (Data.Functor.Adjunction.Adjunction f u, Data.Functor.Adjunction.Adjunction f' u') => Data.Functor.Adjunction.Adjunction (Data.Functor.Day.Day f f') (Data.Functor.Day.Day u u')
instance (GHC.Internal.Base.Applicative f, GHC.Internal.Base.Applicative g) => GHC.Internal.Base.Applicative (Data.Functor.Day.Day f g)
instance (Control.Comonad.ComonadApply f, Control.Comonad.ComonadApply g) => Control.Comonad.ComonadApply (Data.Functor.Day.Day f g)
instance (Control.Comonad.Comonad f, Control.Comonad.Comonad g) => Control.Comonad.Comonad (Data.Functor.Day.Day f g)
instance Control.Comonad.Comonad f => Control.Comonad.Trans.Class.ComonadTrans (Data.Functor.Day.Day f)
instance (Data.Functor.Rep.Representable f, Data.Functor.Rep.Representable g) => Data.Distributive.Distributive (Data.Functor.Day.Day f g)
instance GHC.Internal.Base.Functor (Data.Functor.Day.Day f g)
instance (Data.Functor.Rep.Representable f, Data.Functor.Rep.Representable g) => Data.Functor.Rep.Representable (Data.Functor.Day.Day f g)


-- | <pre>
--   <a>Day</a> f -| <a>Curried</a> f
--   </pre>
--   
--   <tt><a>Day</a> f ~ <tt>Compose</tt> f</tt> when f preserves colimits /
--   is a left adjoint. (Due in part to the strength of all functors in
--   Hask.)
--   
--   So by the uniqueness of adjoints, when f is a left adjoint,
--   <tt><a>Curried</a> f ~ <tt>Rift</tt> f</tt>
module Data.Functor.Day.Curried
newtype Curried (g :: Type -> Type) (h :: Type -> Type) a
Curried :: (forall r. () => g (a -> r) -> h r) -> Curried (g :: Type -> Type) (h :: Type -> Type) a
[runCurried] :: Curried (g :: Type -> Type) (h :: Type -> Type) a -> forall r. () => g (a -> r) -> h r

-- | The universal property of <a>Curried</a>
toCurried :: forall (g :: Type -> Type) k h a. (forall x. () => Day g k x -> h x) -> k a -> Curried g h a

-- | <pre>
--   <a>toCurried</a> . <a>fromCurried</a> ≡ <a>id</a>
--   <a>fromCurried</a> . <a>toCurried</a> ≡ <a>id</a>
--   </pre>
fromCurried :: forall (f :: Type -> Type) k h b. Functor f => (forall a. () => k a -> Curried f h a) -> Day f k b -> h b

-- | This is the counit of the <tt>Day f -| Curried f</tt> adjunction
applied :: forall (f :: Type -> Type) g a. Functor f => Day f (Curried f g) a -> g a

-- | This is the unit of the <tt>Day f -| Curried f</tt> adjunction
unapplied :: forall g a (f :: Type -> Type). g a -> Curried f (Day f g) a

-- | <tt>Curried f Identity a</tt> is isomorphic to the right adjoint to
--   <tt>f</tt> if one exists.
--   
--   <pre>
--   <a>adjointToCurried</a> . <a>curriedToAdjoint</a> ≡ <a>id</a>
--   <a>curriedToAdjoint</a> . <a>adjointToCurried</a> ≡ <a>id</a>
--   </pre>
adjointToCurried :: forall (f :: Type -> Type) u a. Adjunction f u => u a -> Curried f Identity a

-- | <tt>Curried f Identity a</tt> is isomorphic to the right adjoint to
--   <tt>f</tt> if one exists.
curriedToAdjoint :: forall (f :: Type -> Type) u a. Adjunction f u => Curried f Identity a -> u a

-- | <tt>Curried f h a</tt> is isomorphic to the post-composition of the
--   right adjoint of <tt>f</tt> onto <tt>h</tt> if such a right adjoint
--   exists.
composedAdjointToCurried :: forall h (f :: Type -> Type) u a. (Functor h, Adjunction f u) => u (h a) -> Curried f h a

-- | <tt>Curried f h a</tt> is isomorphic to the post-composition of the
--   right adjoint of <tt>f</tt> onto <tt>h</tt> if such a right adjoint
--   exists.
--   
--   <pre>
--   <a>curriedToComposedAdjoint</a> . <a>composedAdjointToCurried</a> ≡ <a>id</a>
--   <a>composedAdjointToCurried</a> . <a>curriedToComposedAdjoint</a> ≡ <a>id</a>
--   </pre>
curriedToComposedAdjoint :: forall (f :: Type -> Type) u h a. Adjunction f u => Curried f h a -> u (h a)

-- | The natural isomorphism between <tt>f</tt> and <tt>Curried f f</tt>.
--   <tt> <a>lowerCurried</a> <a>.</a> <a>liftCurried</a> ≡ <a>id</a>
--   <a>liftCurried</a> <a>.</a> <a>lowerCurried</a> ≡ <a>id</a> </tt>
--   
--   <pre>
--   <a>lowerCurried</a> (<a>liftCurried</a> x)     -- definition
--   <a>lowerCurried</a> (<a>Curried</a> (<a>&lt;*&gt;</a> x))   -- definition
--   (<a>&lt;*&gt;</a> x) (<a>pure</a> <a>id</a>)          -- beta reduction
--   <a>pure</a> <a>id</a> <a>&lt;*&gt;</a> x              -- Applicative identity law
--   x
--   </pre>
liftCurried :: Applicative f => f a -> Curried f f a

-- | Lower <a>Curried</a> by applying <a>pure</a> <a>id</a> to the
--   continuation.
--   
--   See <a>liftCurried</a>.
lowerCurried :: forall (f :: Type -> Type) g a. Applicative f => Curried f g a -> g a

-- | Indexed applicative composition of right Kan lifts.
rap :: forall (f :: Type -> Type) (g :: Type -> Type) a b (h :: Type -> Type). Functor f => Curried f g (a -> b) -> Curried g h a -> Curried f h b
instance (GHC.Internal.Base.Functor g, g GHC.Types.~ h) => GHC.Internal.Base.Applicative (Data.Functor.Day.Curried.Curried g h)
instance (GHC.Internal.Base.Functor g, g GHC.Types.~ h) => Data.Functor.Bind.Class.Apply (Data.Functor.Day.Curried.Curried g h)
instance GHC.Internal.Base.Functor g => GHC.Internal.Base.Functor (Data.Functor.Day.Curried.Curried g h)


-- | The Day convolution of two invariant functors is an invariant functor.
--   
--   <a>http://ncatlab.org/nlab/show/Day+convolution</a>
module Data.Functor.Invariant.Day

-- | The Day convolution of two invariant functors.
data Day (f :: Type -> Type) (g :: Type -> Type) a
Day :: f b -> g c -> (b -> c -> a) -> (a -> (b, c)) -> Day (f :: Type -> Type) (g :: Type -> Type) a

-- | Construct the Day convolution
day :: f a -> g b -> Day f g (a, b)

-- | Day convolution provides a monoidal product. The associativity of this
--   monoid is witnessed by <a>assoc</a> and <a>disassoc</a>.
--   
--   <pre>
--   <a>assoc</a> . <a>disassoc</a> = <a>id</a>
--   <a>disassoc</a> . <a>assoc</a> = <a>id</a>
--   <a>invmap</a> f g <a>.</a> <a>assoc</a> = <a>assoc</a> <a>.</a> <a>invmap</a> f g
--   </pre>
assoc :: forall (f :: Type -> Type) (g :: Type -> Type) (h :: Type -> Type) a. Day f (Day g h) a -> Day (Day f g) h a

-- | Day convolution provides a monoidal product. The associativity of this
--   monoid is witnessed by <a>assoc</a> and <a>disassoc</a>.
--   
--   <pre>
--   <a>assoc</a> . <a>disassoc</a> = <a>id</a>
--   <a>disassoc</a> . <a>assoc</a> = <a>id</a>
--   <a>invmap</a> f g <a>.</a> <a>disassoc</a> = <a>disassoc</a> <a>.</a> <a>invmap</a> f g
--   </pre>
disassoc :: forall (f :: Type -> Type) (g :: Type -> Type) (h :: Type -> Type) a. Day (Day f g) h a -> Day f (Day g h) a

-- | The monoid for <a>Day</a> convolution on the cartesian monoidal
--   structure is symmetric.
--   
--   <pre>
--   <a>invmap</a> f g <a>.</a> <a>swapped</a> = <a>swapped</a> <a>.</a> <a>invmap</a> f g
--   </pre>
swapped :: forall (f :: Type -> Type) (g :: Type -> Type) a. Day f g a -> Day g f a

-- | <a>Identity</a> is the unit of <a>Day</a> convolution
--   
--   <pre>
--   <a>intro1</a> <a>.</a> <a>elim1</a> = <a>id</a>
--   <a>elim1</a> <a>.</a> <a>intro1</a> = <a>id</a>
--   </pre>
intro1 :: f a -> Day Identity f a

-- | <a>Identity</a> is the unit of <a>Day</a> convolution
--   
--   <pre>
--   <a>intro2</a> <a>.</a> <a>elim2</a> = <a>id</a>
--   <a>elim2</a> <a>.</a> <a>intro2</a> = <a>id</a>
--   </pre>
intro2 :: f a -> Day f Identity a

-- | <a>Identity</a> is the unit of <a>Day</a> convolution
--   
--   <pre>
--   <a>intro1</a> <a>.</a> <a>elim1</a> = <a>id</a>
--   <a>elim1</a> <a>.</a> <a>intro1</a> = <a>id</a>
--   </pre>
elim1 :: Invariant f => Day Identity f a -> f a

-- | <a>Identity</a> is the unit of <a>Day</a> convolution
--   
--   <pre>
--   <a>intro2</a> <a>.</a> <a>elim2</a> = <a>id</a>
--   <a>elim2</a> <a>.</a> <a>intro2</a> = <a>id</a>
--   </pre>
elim2 :: Invariant f => Day f Identity a -> f a

-- | Apply a natural transformation to the left-hand side of a Day
--   convolution.
--   
--   This respects the naturality of the natural transformation you
--   supplied:
--   
--   <pre>
--   <a>invmap</a> f g <a>.</a> <a>trans1</a> fg = <a>trans1</a> fg <a>.</a> <a>invmap</a> f g
--   </pre>
trans1 :: forall f g (h :: Type -> Type) a. (forall x. () => f x -> g x) -> Day f h a -> Day g h a

-- | Apply a natural transformation to the right-hand side of a Day
--   convolution.
--   
--   This respects the naturality of the natural transformation you
--   supplied:
--   
--   <pre>
--   <a>invmap</a> f g <a>.</a> <a>trans2</a> fg = <a>trans2</a> fg <a>.</a> <a>invmap</a> f g
--   </pre>
trans2 :: forall g h (f :: Type -> Type) a. (forall x. () => g x -> h x) -> Day f g a -> Day f h a

-- | Drop the covariant part of the Day convolution.
toContravariant :: forall (f :: Type -> Type) (g :: Type -> Type) a. Day f g a -> Day f g a

-- | Drop the contravariant part of the Day convolution.
toCovariant :: forall (f :: Type -> Type) (g :: Type -> Type) a. Day f g a -> Day f g a
instance Data.Functor.Invariant.Invariant (Data.Functor.Invariant.Day.Day f g)


-- | Left Kan Extensions
module Data.Functor.Kan.Lan

-- | The left Kan extension of a <a>Functor</a> <tt>h</tt> along a
--   <a>Functor</a> <tt>g</tt>.
data Lan (g :: k -> Type) (h :: k -> Type) a
[Lan] :: forall {k} (g :: k -> Type) (b :: k) a (h :: k -> Type). (g b -> a) -> h b -> Lan g h a

-- | The universal property of a left Kan extension.
toLan :: forall {k} f h g b. Functor f => (forall (a :: k). () => h a -> f (g a)) -> Lan g h b -> f b

-- | <a>fromLan</a> and <a>toLan</a> witness a (higher kinded) adjunction
--   between <tt><a>Lan</a> g</tt> and <tt>(<tt>Compose</tt> g)</tt>
--   
--   <pre>
--   <a>toLan</a> . <a>fromLan</a> ≡ <a>id</a>
--   <a>fromLan</a> . <a>toLan</a> ≡ <a>id</a>
--   </pre>
fromLan :: forall {k} g h f (b :: k). (forall a. () => Lan g h a -> f a) -> h b -> f (g b)

-- | This is the natural transformation that defines a Left Kan extension.
glan :: forall {k} h (a :: k) g. h a -> Lan g h (g a)

-- | <a>composeLan</a> and <a>decomposeLan</a> witness the natural
--   isomorphism from <tt>Lan f (Lan g h)</tt> and <tt>Lan (f <tt>o</tt> g)
--   h</tt>
--   
--   <pre>
--   <a>composeLan</a> . <a>decomposeLan</a> ≡ <a>id</a>
--   <a>decomposeLan</a> . <a>composeLan</a> ≡ <a>id</a>
--   </pre>
composeLan :: forall (compose :: (Type -> Type) -> (Type -> Type) -> Type -> Type) (f :: Type -> Type) (g :: Type -> Type) (h :: Type -> Type) a. (Composition compose, Functor f) => Lan f (Lan g h) a -> Lan (compose f g) h a
decomposeLan :: forall (compose :: (Type -> Type) -> (Type -> Type) -> Type -> Type) (f :: Type -> Type) (g :: Type -> Type) (h :: Type -> Type) a. Composition compose => Lan (compose f g) h a -> Lan f (Lan g h) a

-- | <pre>
--   <a>adjointToLan</a> . <a>lanToAdjoint</a> ≡ <a>id</a>
--   <a>lanToAdjoint</a> . <a>adjointToLan</a> ≡ <a>id</a>
--   </pre>
adjointToLan :: forall (f :: Type -> Type) g a. Adjunction f g => g a -> Lan f Identity a
lanToAdjoint :: forall (f :: Type -> Type) g a. Adjunction f g => Lan f Identity a -> g a
composedAdjointToLan :: forall (f :: Type -> Type) g h a. Adjunction f g => h (g a) -> Lan f h a

-- | <a>lanToComposedAdjoint</a> and <a>composedAdjointToLan</a> witness
--   the natural isomorphism between <tt>Lan f h</tt> and <tt>Compose h
--   g</tt> given <tt>f -| g</tt>
--   
--   <pre>
--   <a>composedAdjointToLan</a> . <a>lanToComposedAdjoint</a> ≡ <a>id</a>
--   <a>lanToComposedAdjoint</a> . <a>composedAdjointToLan</a> ≡ <a>id</a>
--   </pre>
lanToComposedAdjoint :: forall h (f :: Type -> Type) g a. (Functor h, Adjunction f g) => Lan f h a -> h (g a)
instance (GHC.Internal.Base.Functor g, GHC.Internal.Base.Applicative h) => GHC.Internal.Base.Applicative (Data.Functor.Kan.Lan.Lan g h)
instance (GHC.Internal.Base.Functor g, Data.Functor.Bind.Class.Apply h) => Data.Functor.Bind.Class.Apply (Data.Functor.Kan.Lan.Lan g h)
instance forall k (f :: k -> *) (g :: k -> *). GHC.Internal.Base.Functor (Data.Functor.Kan.Lan.Lan f g)


-- | <tt><a>Coyoneda</a> f</tt> is the "free functor" over <tt>f</tt>. The
--   co-Yoneda lemma for a covariant <a>Functor</a> <tt>f</tt> states that
--   <tt><a>Coyoneda</a> f</tt> is naturally isomorphic to <tt>f</tt>.
module Data.Functor.Coyoneda

-- | A covariant <a>Functor</a> suitable for Yoneda reduction
data Coyoneda (f :: Type -> Type) a
[Coyoneda] :: forall b a (f :: Type -> Type). (b -> a) -> f b -> Coyoneda f a

-- | Yoneda "expansion"
--   
--   <pre>
--   <a>liftCoyoneda</a> . <a>lowerCoyoneda</a> ≡ <a>id</a>
--   <a>lowerCoyoneda</a> . <a>liftCoyoneda</a> ≡ <a>id</a>
--   </pre>
--   
--   <pre>
--   lowerCoyoneda (liftCoyoneda fa) = -- by definition
--   lowerCoyoneda (Coyoneda id fa)  = -- by definition
--   fmap id fa                      = -- functor law
--   fa
--   </pre>
--   
--   <pre>
--   <a>lift</a> = <a>liftCoyoneda</a>
--   </pre>
liftCoyoneda :: f a -> Coyoneda f a

-- | Yoneda reduction lets us walk under the existential and apply
--   <a>fmap</a>.
--   
--   Mnemonically, "Yoneda reduction" sounds like and works a bit like
--   β-reduction.
--   
--   <a>http://ncatlab.org/nlab/show/Yoneda+reduction</a>
--   
--   You can view <a>Coyoneda</a> as just the arguments to <a>fmap</a>
--   tupled up.
--   
--   <pre>
--   <a>lower</a> = <a>lowerM</a> = <a>lowerCoyoneda</a>
--   </pre>
lowerCoyoneda :: Functor f => Coyoneda f a -> f a

-- | Yoneda reduction given a <a>Monad</a> lets us walk under the
--   existential and apply <a>liftM</a>.
--   
--   You can view <a>Coyoneda</a> as just the arguments to <a>liftM</a>
--   tupled up.
--   
--   <pre>
--   <a>lower</a> = <a>lowerM</a> = <a>lowerCoyoneda</a>
--   </pre>
lowerM :: Monad f => Coyoneda f a -> f a

-- | Lift a natural transformation from <tt>f</tt> to <tt>g</tt> to a
--   natural transformation from <tt>Coyoneda f</tt> to <tt>Coyoneda
--   g</tt>.
hoistCoyoneda :: (forall a. () => f a -> g a) -> Coyoneda f b -> Coyoneda g b

-- | <tt>Coyoneda f</tt> is the left Kan extension of <tt>f</tt> along the
--   <a>Identity</a> functor.
--   
--   <tt>Coyoneda f</tt> is always a functor, even if <tt>f</tt> is not. In
--   this case, it is called the <i>free functor over <tt>f</tt></i>. Note
--   the following categorical fine print: If <tt>f</tt> is not a functor,
--   <tt>Coyoneda f</tt> is actually not the left Kan extension of
--   <tt>f</tt> along the <a>Identity</a> functor, but along the inclusion
--   functor from the discrete subcategory of <i>Hask</i> which contains
--   only identity functions as morphisms to the full category <i>Hask</i>.
--   (This is because <tt>f</tt>, not being a proper functor, can only be
--   interpreted as a categorical functor by restricting the source
--   category to only contain identities.)
--   
--   <pre>
--   <a>coyonedaToLan</a> . <a>lanToCoyoneda</a> ≡ <a>id</a>
--   <a>lanToCoyoneda</a> . <a>coyonedaToLan</a> ≡ <a>id</a>
--   </pre>
coyonedaToLan :: forall (f :: Type -> Type) a. Coyoneda f a -> Lan Identity f a
lanToCoyoneda :: forall (f :: Type -> Type) a. Lan Identity f a -> Coyoneda f a
instance Data.Functor.Adjunction.Adjunction f g => Data.Functor.Adjunction.Adjunction (Data.Functor.Coyoneda.Coyoneda f) (Data.Functor.Coyoneda.Coyoneda g)
instance Data.Functor.Alt.Alt f => Data.Functor.Alt.Alt (Data.Functor.Coyoneda.Coyoneda f)
instance GHC.Internal.Base.Alternative f => GHC.Internal.Base.Alternative (Data.Functor.Coyoneda.Coyoneda f)
instance GHC.Internal.Base.Applicative f => GHC.Internal.Base.Applicative (Data.Functor.Coyoneda.Coyoneda f)
instance Data.Functor.Bind.Class.Apply f => Data.Functor.Bind.Class.Apply (Data.Functor.Coyoneda.Coyoneda f)
instance Data.Functor.Bind.Class.Bind m => Data.Functor.Bind.Class.Bind (Data.Functor.Coyoneda.Coyoneda m)
instance Control.Comonad.Comonad w => Control.Comonad.Comonad (Data.Functor.Coyoneda.Coyoneda w)
instance Control.Comonad.Trans.Class.ComonadTrans Data.Functor.Coyoneda.Coyoneda
instance Data.Distributive.Distributive f => Data.Distributive.Distributive (Data.Functor.Coyoneda.Coyoneda f)
instance Data.Functor.Classes.Eq1 f => Data.Functor.Classes.Eq1 (Data.Functor.Coyoneda.Coyoneda f)
instance (Data.Functor.Classes.Eq1 f, GHC.Classes.Eq a) => GHC.Classes.Eq (Data.Functor.Coyoneda.Coyoneda f a)
instance Data.Functor.Extend.Extend w => Data.Functor.Extend.Extend (Data.Functor.Coyoneda.Coyoneda w)
instance Data.Foldable1.Foldable1 f => Data.Foldable1.Foldable1 (Data.Functor.Coyoneda.Coyoneda f)
instance GHC.Internal.Data.Foldable.Foldable f => GHC.Internal.Data.Foldable.Foldable (Data.Functor.Coyoneda.Coyoneda f)
instance GHC.Internal.Base.Functor (Data.Functor.Coyoneda.Coyoneda f)
instance GHC.Internal.Base.Monad m => GHC.Internal.Base.Monad (Data.Functor.Coyoneda.Coyoneda m)
instance GHC.Internal.Control.Monad.Fix.MonadFix f => GHC.Internal.Control.Monad.Fix.MonadFix (Data.Functor.Coyoneda.Coyoneda f)
instance GHC.Internal.Base.MonadPlus f => GHC.Internal.Base.MonadPlus (Data.Functor.Coyoneda.Coyoneda f)
instance Control.Monad.Trans.Class.MonadTrans Data.Functor.Coyoneda.Coyoneda
instance Data.Functor.Classes.Ord1 f => Data.Functor.Classes.Ord1 (Data.Functor.Coyoneda.Coyoneda f)
instance (Data.Functor.Classes.Ord1 f, GHC.Classes.Ord a) => GHC.Classes.Ord (Data.Functor.Coyoneda.Coyoneda f a)
instance Data.Functor.Plus.Plus f => Data.Functor.Plus.Plus (Data.Functor.Coyoneda.Coyoneda f)
instance Data.Functor.Classes.Read1 f => Data.Functor.Classes.Read1 (Data.Functor.Coyoneda.Coyoneda f)
instance GHC.Internal.Read.Read (f a) => GHC.Internal.Read.Read (Data.Functor.Coyoneda.Coyoneda f a)
instance Data.Functor.Rep.Representable f => Data.Functor.Rep.Representable (Data.Functor.Coyoneda.Coyoneda f)
instance (GHC.Internal.Base.Functor f, Data.Functor.Classes.Show1 f) => Data.Functor.Classes.Show1 (Data.Functor.Coyoneda.Coyoneda f)
instance (GHC.Internal.Base.Functor f, Data.Functor.Classes.Show1 f, GHC.Internal.Show.Show a) => GHC.Internal.Show.Show (Data.Functor.Coyoneda.Coyoneda f a)
instance Data.Semigroup.Traversable.Class.Traversable1 f => Data.Semigroup.Traversable.Class.Traversable1 (Data.Functor.Coyoneda.Coyoneda f)
instance GHC.Internal.Data.Traversable.Traversable f => GHC.Internal.Data.Traversable.Traversable (Data.Functor.Coyoneda.Coyoneda f)


-- | The <a>Density</a> <a>Comonad</a> for a <a>Functor</a> (aka the
--   'Comonad generated by a <a>Functor</a>) The <a>Density</a> term dates
--   back to Dubuc''s 1974 thesis. The term <a>Monad</a> generated by a
--   <a>Functor</a> dates back to 1972 in Street''s ''Formal Theory of
--   Monads''.
--   
--   The left Kan extension of a <a>Functor</a> along itself
--   (<tt><a>Lan</a> f f</tt>) forms a <a>Comonad</a>. This is that
--   <a>Comonad</a>.
module Control.Comonad.Density
data Density (k1 :: k -> Type) a
[Density] :: forall {k} (k1 :: k -> Type) (b :: k) a. (k1 b -> a) -> k1 b -> Density k1 a

-- | The natural transformation from a <tt><a>Comonad</a> w</tt> to the
--   <a>Comonad</a> generated by <tt>w</tt> (forwards).
--   
--   This is merely a right-inverse (section) of <a>lower</a>, rather than
--   a full inverse.
--   
--   <pre>
--   <a>lower</a> . <a>liftDensity</a> ≡ <a>id</a>
--   </pre>
liftDensity :: Comonad w => w a -> Density w a

-- | The Density <a>Comonad</a> of a left adjoint is isomorphic to the
--   <a>Comonad</a> formed by that <a>Adjunction</a>.
--   
--   This isomorphism is witnessed by <a>densityToAdjunction</a> and
--   <a>adjunctionToDensity</a>.
--   
--   <pre>
--   <a>densityToAdjunction</a> . <a>adjunctionToDensity</a> ≡ <a>id</a>
--   <a>adjunctionToDensity</a> . <a>densityToAdjunction</a> ≡ <a>id</a>
--   </pre>
densityToAdjunction :: Adjunction f g => Density f a -> f (g a)
adjunctionToDensity :: Adjunction f g => f (g a) -> Density f a
densityToLan :: forall {k} (f :: k -> Type) a. Density f a -> Lan f f a

-- | The <a>Density</a> <a>Comonad</a> of a <a>Functor</a> <tt>f</tt> is
--   obtained by taking the left Kan extension (<a>Lan</a>) of <tt>f</tt>
--   along itself. This isomorphism is witnessed by <a>lanToDensity</a> and
--   <a>densityToLan</a>
--   
--   <pre>
--   <a>lanToDensity</a> . <a>densityToLan</a> ≡ <a>id</a>
--   <a>densityToLan</a> . <a>lanToDensity</a> ≡ <a>id</a>
--   </pre>
lanToDensity :: forall {k} (f :: k -> Type) a. Lan f f a -> Density f a
instance GHC.Internal.Base.Applicative f => GHC.Internal.Base.Applicative (Control.Comonad.Density.Density f)
instance Data.Functor.Bind.Class.Apply f => Data.Functor.Bind.Class.Apply (Control.Comonad.Density.Density f)
instance forall k (f :: k -> *). Control.Comonad.Comonad (Control.Comonad.Density.Density f)
instance Control.Comonad.Trans.Class.ComonadTrans Control.Comonad.Density.Density
instance forall k (f :: k -> *). Data.Functor.Extend.Extend (Control.Comonad.Density.Density f)
instance forall k (f :: k -> *). GHC.Internal.Base.Functor (Control.Comonad.Density.Density f)


-- | Monads from Comonads
--   
--   <a>http://comonad.com/reader/2011/monads-from-comonads/</a>
--   
--   <a>Co</a> can be viewed as a right Kan lift along a <a>Comonad</a>.
--   
--   In general you can "sandwich" a monad in between two halves of an
--   adjunction. That is to say, if you have an adjunction <tt>F -| G : C
--   -&gt; D </tt> then not only does <tt>GF</tt> form a monad, but
--   <tt>GMF</tt> forms a monad for <tt>M</tt> a monad in <tt>D</tt>.
--   Therefore if we have an adjunction <tt>F -| G : Hask -&gt;
--   Hask^op</tt> then we can lift a <a>Comonad</a> in <tt>Hask</tt> which
--   is a <a>Monad</a> in <tt>Hask^op</tt> to a <a>Monad</a> in
--   <tt>Hask</tt>.
--   
--   For any <tt>r</tt>, the <tt>Contravariant</tt> functor / presheaf
--   <tt>(-&gt; r)</tt> :: Hask^op -&gt; Hask is adjoint to the "same"
--   <tt>Contravariant</tt> functor <tt>(-&gt; r) :: Hask -&gt;
--   Hask^op</tt>. So we can sandwich a Monad in Hask^op in the middle to
--   obtain <tt>w (a -&gt; r-) -&gt; r+</tt>, and then take a coend over
--   <tt>r</tt> to obtain <tt>forall r. w (a -&gt; r) -&gt; r</tt>. This
--   gives rise to <a>Co</a>. If we observe that we didn't care what the
--   choices we made for <tt>r</tt> were to finish this construction, we
--   can upgrade to <tt>forall r. w (a -&gt; m r) -&gt; m r</tt> in a
--   manner similar to how <tt>ContT</tt> is constructed yielding
--   <a>CoT</a>.
--   
--   We could consider unifying the definition of <a>Co</a> and
--   <tt>Rift</tt>, but there are many other arguments for which
--   <tt>Rift</tt> can form a <a>Monad</a>, and this wouldn't give rise to
--   <a>CoT</a>.
module Control.Monad.Co
type Co (w :: Type -> Type) = CoT w Identity
co :: Functor w => (forall r. () => w (a -> r) -> r) -> Co w a
runCo :: Functor w => Co w a -> w (a -> r) -> r

-- | <pre>
--   <a>Co</a> w a ~ <a>Rift</a> w <a>Identity</a> a
--   </pre>
newtype CoT (w :: Type -> Type) (m :: k -> Type) a
CoT :: (forall (r :: k). () => w (a -> m r) -> m r) -> CoT (w :: Type -> Type) (m :: k -> Type) a
[runCoT] :: CoT (w :: Type -> Type) (m :: k -> Type) a -> forall (r :: k). () => w (a -> m r) -> m r
liftCoT0 :: forall {k} w s (m :: k -> Type). Comonad w => (forall a. () => w a -> s) -> CoT w m s
liftCoT0M :: (Comonad w, Monad m) => (forall a. () => w a -> m s) -> CoT w m s
lowerCoT0 :: (Functor w, Monad m) => CoT w m s -> w a -> m s
lowerCo0 :: Functor w => Co w s -> w a -> s
liftCoT1 :: forall {k} w (m :: k -> Type). (forall a. () => w a -> a) -> CoT w m ()
liftCoT1M :: Monad m => (forall a. () => w a -> m a) -> CoT w m ()
lowerCoT1 :: (Functor w, Monad m) => CoT w m () -> w a -> m a
lowerCo1 :: Functor w => Co w () -> w a -> a
diter :: Functor f => a -> (a -> f a) -> Density (Cofree f) a
dctrlM :: forall {k} m w. Monad m => (forall (a :: k). () => w a -> m (w a)) -> CoT (Density w) m ()
posW :: forall {k} s (w :: Type -> Type) (m :: k -> Type). ComonadStore s w => CoT w m s
peekW :: forall {k} s (w :: Type -> Type) (m :: k -> Type). ComonadStore s w => s -> CoT w m ()
peeksW :: forall {k} s (w :: Type -> Type) (m :: k -> Type). ComonadStore s w => (s -> s) -> CoT w m ()
askW :: forall {k} e (w :: Type -> Type) (m :: k -> Type). ComonadEnv e w => CoT w m e
asksW :: forall {k} e (w :: Type -> Type) a (m :: k -> Type). ComonadEnv e w => (e -> a) -> CoT w m a
traceW :: forall {k} e (w :: Type -> Type) (m :: k -> Type). ComonadTraced e w => e -> CoT w m ()
instance forall k (w :: * -> *) (m :: k -> *). Control.Comonad.Comonad w => GHC.Internal.Base.Applicative (Control.Monad.Co.CoT w m)
instance forall k (w :: * -> *) (m :: k -> *). Data.Functor.Extend.Extend w => Data.Functor.Bind.Class.Apply (Control.Monad.Co.CoT w m)
instance forall k (w :: * -> *) (m :: k -> *). Data.Functor.Extend.Extend w => Data.Functor.Bind.Class.Bind (Control.Monad.Co.CoT w m)
instance forall k (w :: * -> *) (m :: k -> *). GHC.Internal.Base.Functor w => GHC.Internal.Base.Functor (Control.Monad.Co.CoT w m)
instance forall k (w :: * -> *) (m :: k -> *). Control.Comonad.Comonad w => GHC.Internal.Base.Monad (Control.Monad.Co.CoT w m)
instance (Control.Comonad.Comonad w, Control.Monad.Error.Class.MonadError e m) => Control.Monad.Error.Class.MonadError e (Control.Monad.Co.CoT w m)
instance (Control.Comonad.Comonad w, GHC.Internal.Control.Monad.Fail.MonadFail m) => GHC.Internal.Control.Monad.Fail.MonadFail (Control.Monad.Co.CoT w m)
instance (Control.Comonad.Comonad w, Control.Monad.IO.Class.MonadIO m) => Control.Monad.IO.Class.MonadIO (Control.Monad.Co.CoT w m)
instance (Control.Comonad.Comonad w, Control.Monad.Reader.Class.MonadReader e m) => Control.Monad.Reader.Class.MonadReader e (Control.Monad.Co.CoT w m)
instance (Control.Comonad.Comonad w, Control.Monad.State.Class.MonadState s m) => Control.Monad.State.Class.MonadState s (Control.Monad.Co.CoT w m)
instance Control.Comonad.Comonad w => Control.Monad.Trans.Class.MonadTrans (Control.Monad.Co.CoT w)
instance (Control.Comonad.Comonad w, Control.Monad.Writer.Class.MonadWriter e m) => Control.Monad.Writer.Class.MonadWriter e (Control.Monad.Co.CoT w m)


-- | <ul>
--   <li>Right Kan Extensions</li>
--   </ul>
module Data.Functor.Kan.Ran

-- | The right Kan extension of a <a>Functor</a> h along a <a>Functor</a>
--   g.
--   
--   We can define a right Kan extension in several ways. The definition
--   here is obtained by reading off the definition in of a right Kan
--   extension in terms of an End, but we can derive an equivalent
--   definition from the universal property.
--   
--   Given a <a>Functor</a> <tt>h : C -&gt; D</tt> and a <a>Functor</a>
--   <tt>g : C -&gt; C'</tt>, we want to extend <tt>h</tt> <i>back</i>
--   along <tt>g</tt> to give <tt>Ran g h : C' -&gt; D</tt>, such that the
--   natural transformation <tt><a>gran</a> :: Ran g h (g a) -&gt; h a</tt>
--   exists.
--   
--   In some sense this is trying to approximate the inverse of <tt>g</tt>
--   by using one of its adjoints, because if the adjoint and the inverse
--   both exist, they match!
--   
--   <pre>
--   Hask -h-&gt; Hask
--     |       +
--     g      /
--     |    Ran g h
--     v    /
--   Hask -'
--   </pre>
--   
--   The Right Kan extension is unique (up to isomorphism) by taking this
--   as its universal property.
--   
--   That is to say given any <tt>K : C' -&gt; D</tt> such that we have a
--   natural transformation from <tt>k.g</tt> to <tt>h</tt> <tt>(forall x.
--   k (g x) -&gt; h x)</tt> there exists a canonical natural
--   transformation from <tt>k</tt> to <tt>Ran g h</tt>. <tt>(forall x. k x
--   -&gt; Ran g h x)</tt>.
--   
--   We could literally read this off as a valid Rank-3 definition for
--   <a>Ran</a>:
--   
--   <pre>
--   data Ran' g h a = forall z. <a>Functor</a> z =&gt; Ran' (forall x. z (g x) -&gt; h x) (z a)
--   </pre>
--   
--   This definition is isomorphic the simpler Rank-2 definition we use
--   below as witnessed by the
--   
--   <pre>
--   ranIso1 :: Ran g f x -&gt; Ran' g f x
--   ranIso1 (Ran e) = Ran' e id
--   </pre>
--   
--   <pre>
--   ranIso2 :: Ran' g f x -&gt; Ran g f x
--   ranIso2 (Ran' h z) = Ran $ \k -&gt; h (k &lt;$&gt; z)
--   </pre>
--   
--   <pre>
--   ranIso2 (ranIso1 (Ran e)) ≡ -- by definition
--   ranIso2 (Ran' e id) ≡       -- by definition
--   Ran $ \k -&gt; e (k &lt;$&gt; id)    -- by definition
--   Ran $ \k -&gt; e (k . id)      -- f . id = f
--   Ran $ \k -&gt; e k             -- eta reduction
--   Ran e
--   </pre>
--   
--   The other direction is left as an exercise for the reader.
newtype Ran (g :: k -> Type) (h :: k -> Type) a
Ran :: (forall (b :: k). () => (a -> g b) -> h b) -> Ran (g :: k -> Type) (h :: k -> Type) a
[runRan] :: Ran (g :: k -> Type) (h :: k -> Type) a -> forall (b :: k). () => (a -> g b) -> h b

-- | The universal property of a right Kan extension.
toRan :: forall {k1} k2 g h b. Functor k2 => (forall (a :: k1). () => k2 (g a) -> h a) -> k2 b -> Ran g h b

-- | <a>toRan</a> and <a>fromRan</a> witness a higher kinded adjunction.
--   from <tt>(`<tt>Compose'</tt> g)</tt> to <tt><a>Ran</a> g</tt>
--   
--   <pre>
--   <a>toRan</a> . <a>fromRan</a> ≡ <a>id</a>
--   <a>fromRan</a> . <a>toRan</a> ≡ <a>id</a>
--   </pre>
fromRan :: forall {k1} k2 g h (b :: k1). (forall a. () => k2 a -> Ran g h a) -> k2 (g b) -> h b

-- | This is the natural transformation that defines a Right Kan extension.
gran :: forall {k} g h (a :: k). Ran g h (g a) -> h a

-- | <pre>
--   <a>composeRan</a> . <a>decomposeRan</a> ≡ <a>id</a>
--   <a>decomposeRan</a> . <a>composeRan</a> ≡ <a>id</a>
--   </pre>
composeRan :: forall (compose :: (Type -> Type) -> (Type -> Type) -> Type -> Type) (f :: Type -> Type) (g :: Type -> Type) (h :: Type -> Type) a. Composition compose => Ran f (Ran g h) a -> Ran (compose f g) h a
decomposeRan :: forall (compose :: (Type -> Type) -> (Type -> Type) -> Type -> Type) (f :: Type -> Type) (g :: Type -> Type) (h :: Type -> Type) a. (Composition compose, Functor f) => Ran (compose f g) h a -> Ran f (Ran g h) a

-- | <pre>
--   <a>adjointToRan</a> . <a>ranToAdjoint</a> ≡ <a>id</a>
--   <a>ranToAdjoint</a> . <a>adjointToRan</a> ≡ <a>id</a>
--   </pre>
adjointToRan :: forall f (g :: Type -> Type) a. Adjunction f g => f a -> Ran g Identity a
ranToAdjoint :: forall f (g :: Type -> Type) a. Adjunction f g => Ran g Identity a -> f a
composedAdjointToRan :: forall f (g :: Type -> Type) h a. (Adjunction f g, Functor h) => h (f a) -> Ran g h a

-- | <pre>
--   <a>composedAdjointToRan</a> . <a>ranToComposedAdjoint</a> ≡ <a>id</a>
--   <a>ranToComposedAdjoint</a> . <a>composedAdjointToRan</a> ≡ <a>id</a>
--   </pre>
ranToComposedAdjoint :: forall f (g :: Type -> Type) h a. Adjunction f g => Ran g h a -> h (f a)
repToRan :: forall (u :: Type -> Type) a. Representable u => Rep u -> a -> Ran u Identity a
ranToRep :: forall (u :: Type -> Type) a. Representable u => Ran u Identity a -> (Rep u, a)
composedRepToRan :: forall (u :: Type -> Type) h a. (Representable u, Functor h) => h (Rep u, a) -> Ran u h a
ranToComposedRep :: forall (u :: Type -> Type) h a. Representable u => Ran u h a -> h (Rep u, a)
instance forall k (g :: k -> *) (h :: k -> *). GHC.Internal.Base.Functor (Data.Functor.Kan.Ran.Ran g h)


module Control.Monad.Codensity

-- | <tt><a>Codensity</a> f</tt> is the Monad generated by taking the right
--   Kan extension of any <a>Functor</a> <tt>f</tt> along itself (<tt>Ran f
--   f</tt>).
--   
--   This can often be more "efficient" to construct than <tt>f</tt> itself
--   using repeated applications of <tt>(&gt;&gt;=)</tt>.
--   
--   See "Asymptotic Improvement of Computations over Free Monads" by Janis
--   Voigtländer for more information about this type.
--   
--   
--   <a>https://www.janis-voigtlaender.eu/papers/AsymptoticImprovementOfComputationsOverFreeMonads.pdf</a>
newtype Codensity (m :: k -> TYPE rep) a
Codensity :: (forall (b :: k). () => (a -> m b) -> m b) -> Codensity (m :: k -> TYPE rep) a
[runCodensity] :: Codensity (m :: k -> TYPE rep) a -> forall (b :: k). () => (a -> m b) -> m b

-- | This serves as the *left*-inverse (retraction) of <a>lift</a>.
--   
--   <pre>
--   <a>lowerCodensity</a> . <a>lift</a> ≡ <a>id</a>
--   </pre>
--   
--   In general this is not a full 2-sided inverse, merely a retraction, as
--   <tt><a>Codensity</a> m</tt> is often considerably "larger" than
--   <tt>m</tt>.
--   
--   e.g. <tt><a>Codensity</a> ((-&gt;) s)) a ~ forall r. (a -&gt; s -&gt;
--   r) -&gt; s -&gt; r</tt> could support a full complement of
--   <tt><a>MonadState</a> s</tt> actions, while <tt>(-&gt;) s</tt> is
--   limited to <tt><a>MonadReader</a> s</tt> actions.
lowerCodensity :: Applicative f => Codensity f a -> f a

-- | The <a>Codensity</a> monad of a right adjoint is isomorphic to the
--   monad obtained from the <a>Adjunction</a>.
--   
--   <pre>
--   <a>codensityToAdjunction</a> . <a>adjunctionToCodensity</a> ≡ <a>id</a>
--   <a>adjunctionToCodensity</a> . <a>codensityToAdjunction</a> ≡ <a>id</a>
--   </pre>
codensityToAdjunction :: Adjunction f g => Codensity g a -> g (f a)
adjunctionToCodensity :: Adjunction f g => g (f a) -> Codensity g a

-- | The <a>Codensity</a> <a>Monad</a> of a <a>Functor</a> <tt>g</tt> is
--   the right Kan extension (<a>Ran</a>) of <tt>g</tt> along itself.
--   
--   <pre>
--   <a>codensityToRan</a> . <a>ranToCodensity</a> ≡ <a>id</a>
--   <a>ranToCodensity</a> . <a>codensityToRan</a> ≡ <a>id</a>
--   </pre>
codensityToRan :: forall {k} (g :: k -> Type) a. Codensity g a -> Ran g g a
ranToCodensity :: forall {k} (g :: k -> Type) a. Ran g g a -> Codensity g a

-- | The <a>Codensity</a> monad of a representable <a>Functor</a> is
--   isomorphic to the monad obtained from the <a>Adjunction</a> for which
--   that <a>Functor</a> is the right adjoint.
--   
--   <pre>
--   <a>codensityToComposedRep</a> . <a>composedRepToCodensity</a> ≡ <a>id</a>
--   <a>composedRepToCodensity</a> . <a>codensityToComposedRep</a> ≡ <a>id</a>
--   </pre>
--   
--   <pre>
--   codensityToComposedRep = <a>ranToComposedRep</a> . <a>codensityToRan</a>
--   </pre>
codensityToComposedRep :: Representable u => Codensity u a -> u (Rep u, a)

-- | <pre>
--   <a>composedRepToCodensity</a> = <a>ranToCodensity</a> . <a>composedRepToRan</a>
--   </pre>
composedRepToCodensity :: Representable u => u (Rep u, a) -> Codensity u a

-- | Wrap the remainder of the <a>Codensity</a> action using the given
--   function.
--   
--   This function can be used to register cleanup actions that will be
--   executed at the end. Example:
--   
--   <pre>
--   wrapCodensity (`finally` putStrLn "Done.")
--   </pre>
wrapCodensity :: (forall (a :: k). () => m a -> m a) -> Codensity m ()

-- | Right associate all binds in a computation that generates a free monad
--   
--   This can improve the asymptotic efficiency of the result, while
--   preserving semantics.
--   
--   See "Asymptotic Improvement of Computations over Free Monads" by Janis
--   Voightländer for more information about this combinator.
--   
--   <a>http://www.iai.uni-bonn.de/~jv/mpc08.pdf</a>
improve :: forall (f :: Type -> Type) a. Functor f => (forall (m :: Type -> Type). MonadFree f m => m a) -> Free f a

-- | <tt><a>reset</a> m</tt> delimits the continuation of any <a>shift</a>
--   inside <tt>m</tt>.
--   
--   <ul>
--   <li><pre><a>reset</a> (<a>return</a> m) = <a>return</a> m</pre></li>
--   </ul>
reset :: forall (m :: Type -> Type) a. Monad m => Codensity m a -> Codensity m a

-- | <tt><a>shift</a> f</tt> captures the continuation up to the nearest
--   enclosing <a>reset</a> and passes it to <tt>f</tt>:
--   
--   <ul>
--   <li><pre><a>reset</a> (<a>shift</a> f &gt;&gt;= k) = <a>reset</a> (f
--   (<a>lowerCodensity</a> . k))</pre></li>
--   </ul>
shift :: Applicative m => (forall b. () => (a -> m b) -> Codensity m b) -> Codensity m a
instance forall k (v :: k -> *) (v' :: * -> *). (v GHC.Types.~~ v', Data.Functor.Alt.Alt v') => Data.Functor.Alt.Alt (Control.Monad.Codensity.Codensity v)
instance forall k (v :: k -> *) (v' :: * -> *). (v GHC.Types.~~ v', GHC.Internal.Base.Alternative v') => GHC.Internal.Base.Alternative (Control.Monad.Codensity.Codensity v)
instance forall k (f :: k -> *). GHC.Internal.Base.Applicative (Control.Monad.Codensity.Codensity f)
instance forall k (f :: k -> *). Data.Functor.Bind.Class.Apply (Control.Monad.Codensity.Codensity f)
instance forall j (k :: j -> *). GHC.Internal.Base.Functor (Control.Monad.Codensity.Codensity k)
instance forall k (f :: k -> *). GHC.Internal.Base.Monad (Control.Monad.Codensity.Codensity f)
instance forall k (f :: k -> *) (f' :: * -> *). (f GHC.Types.~~ f', GHC.Internal.Control.Monad.Fail.MonadFail f') => GHC.Internal.Control.Monad.Fail.MonadFail (Control.Monad.Codensity.Codensity f)
instance forall k (m :: k -> *) (m' :: * -> *) (f :: * -> *). (m GHC.Types.~~ m', GHC.Internal.Base.Functor f, Control.Monad.Free.Class.MonadFree f m') => Control.Monad.Free.Class.MonadFree f (Control.Monad.Codensity.Codensity m)
instance forall k (m :: k -> *) (m' :: * -> *). (m GHC.Types.~~ m', Control.Monad.IO.Class.MonadIO m') => Control.Monad.IO.Class.MonadIO (Control.Monad.Codensity.Codensity m)
instance forall k (v :: k -> *) (v' :: * -> *). (v GHC.Types.~~ v', GHC.Internal.Base.Alternative v') => GHC.Internal.Base.MonadPlus (Control.Monad.Codensity.Codensity v)
instance forall k (m :: k -> *) (m' :: * -> *) r. (m GHC.Types.~~ m', Control.Monad.Reader.Class.MonadReader r m') => Control.Monad.Reader.Class.MonadReader r (Control.Monad.Codensity.Codensity m)
instance forall k (m :: k -> *) (m' :: * -> *) r. (m GHC.Types.~~ m', Control.Monad.Reader.Class.MonadReader r m') => Control.Monad.State.Class.MonadState r (Control.Monad.Codensity.Codensity m)
instance Control.Monad.Trans.Class.MonadTrans Control.Monad.Codensity.Codensity
instance forall k (v :: k -> *) (v' :: * -> *). (v GHC.Types.~~ v', Data.Functor.Plus.Plus v') => Data.Functor.Plus.Plus (Control.Monad.Codensity.Codensity v)


-- | The covariant form of the Yoneda lemma states that <tt>f</tt> is
--   naturally isomorphic to <tt>Yoneda f</tt>.
--   
--   This is described in a rather intuitive fashion by Dan Piponi in
--   
--   <a>http://blog.sigfpe.com/2006/11/yoneda-lemma.html</a>
module Data.Functor.Yoneda

-- | <tt>Yoneda f a</tt> can be viewed as the partial application of
--   <a>fmap</a> to its second argument.
newtype Yoneda (f :: Type -> Type) a
Yoneda :: (forall b. () => (a -> b) -> f b) -> Yoneda (f :: Type -> Type) a
[runYoneda] :: Yoneda (f :: Type -> Type) a -> forall b. () => (a -> b) -> f b

-- | The natural isomorphism between <tt>f</tt> and <tt><a>Yoneda</a>
--   f</tt> given by the Yoneda lemma is witnessed by <a>liftYoneda</a> and
--   <a>lowerYoneda</a>
--   
--   <pre>
--   <a>liftYoneda</a> . <a>lowerYoneda</a> ≡ <a>id</a>
--   <a>lowerYoneda</a> . <a>liftYoneda</a> ≡ <a>id</a>
--   </pre>
--   
--   <pre>
--   lowerYoneda (liftYoneda fa) =         -- definition
--   lowerYoneda (Yoneda (f -&gt; fmap f a)) -- definition
--   (f -&gt; fmap f fa) id                  -- beta reduction
--   fmap id fa                            -- functor law
--   fa
--   </pre>
--   
--   <pre>
--   <a>lift</a> = <a>liftYoneda</a>
--   </pre>
liftYoneda :: Functor f => f a -> Yoneda f a
lowerYoneda :: Yoneda f a -> f a
maxF :: forall (f :: Type -> Type) a. (Functor f, Ord (f a)) => Yoneda f a -> Yoneda f a -> Yoneda f a
minF :: forall (f :: Type -> Type) a. (Functor f, Ord (f a)) => Yoneda f a -> Yoneda f a -> Yoneda f a
maxM :: forall (m :: Type -> Type) a. (Monad m, Ord (m a)) => Yoneda m a -> Yoneda m a -> Yoneda m a
minM :: forall (m :: Type -> Type) a. (Monad m, Ord (m a)) => Yoneda m a -> Yoneda m a -> Yoneda m a

-- | <tt>Yoneda f</tt> can be viewed as the right Kan extension of
--   <tt>f</tt> along the <a>Identity</a> functor.
--   
--   <pre>
--   <a>yonedaToRan</a> . <a>ranToYoneda</a> ≡ <a>id</a>
--   <a>ranToYoneda</a> . <a>yonedaToRan</a> ≡ <a>id</a>
--   </pre>
yonedaToRan :: forall (f :: Type -> Type) a. Yoneda f a -> Ran Identity f a
ranToYoneda :: forall (f :: Type -> Type) a. Ran Identity f a -> Yoneda f a
instance Data.Functor.Adjunction.Adjunction f g => Data.Functor.Adjunction.Adjunction (Data.Functor.Yoneda.Yoneda f) (Data.Functor.Yoneda.Yoneda g)
instance Data.Functor.Alt.Alt f => Data.Functor.Alt.Alt (Data.Functor.Yoneda.Yoneda f)
instance GHC.Internal.Base.Alternative f => GHC.Internal.Base.Alternative (Data.Functor.Yoneda.Yoneda f)
instance GHC.Internal.Base.Applicative f => GHC.Internal.Base.Applicative (Data.Functor.Yoneda.Yoneda f)
instance Data.Functor.Bind.Class.Apply f => Data.Functor.Bind.Class.Apply (Data.Functor.Yoneda.Yoneda f)
instance Data.Functor.Bind.Class.Bind m => Data.Functor.Bind.Class.Bind (Data.Functor.Yoneda.Yoneda m)
instance Control.Comonad.Trans.Class.ComonadTrans Data.Functor.Yoneda.Yoneda
instance Control.Comonad.Comonad w => Control.Comonad.Comonad (Data.Functor.Yoneda.Yoneda w)
instance Data.Distributive.Distributive f => Data.Distributive.Distributive (Data.Functor.Yoneda.Yoneda f)
instance Data.Functor.Classes.Eq1 f => Data.Functor.Classes.Eq1 (Data.Functor.Yoneda.Yoneda f)
instance (Data.Functor.Classes.Eq1 f, GHC.Classes.Eq a) => GHC.Classes.Eq (Data.Functor.Yoneda.Yoneda f a)
instance Data.Functor.Extend.Extend w => Data.Functor.Extend.Extend (Data.Functor.Yoneda.Yoneda w)
instance Data.Foldable1.Foldable1 f => Data.Foldable1.Foldable1 (Data.Functor.Yoneda.Yoneda f)
instance GHC.Internal.Data.Foldable.Foldable f => GHC.Internal.Data.Foldable.Foldable (Data.Functor.Yoneda.Yoneda f)
instance GHC.Internal.Base.Functor (Data.Functor.Yoneda.Yoneda f)
instance GHC.Internal.Control.Monad.Fix.MonadFix m => GHC.Internal.Control.Monad.Fix.MonadFix (Data.Functor.Yoneda.Yoneda m)
instance (GHC.Internal.Base.Functor f, Control.Monad.Free.Class.MonadFree f m) => Control.Monad.Free.Class.MonadFree f (Data.Functor.Yoneda.Yoneda m)
instance GHC.Internal.Base.MonadPlus m => GHC.Internal.Base.MonadPlus (Data.Functor.Yoneda.Yoneda m)
instance Control.Monad.Trans.Class.MonadTrans Data.Functor.Yoneda.Yoneda
instance GHC.Internal.Base.Monad m => GHC.Internal.Base.Monad (Data.Functor.Yoneda.Yoneda m)
instance Data.Functor.Classes.Ord1 f => Data.Functor.Classes.Ord1 (Data.Functor.Yoneda.Yoneda f)
instance (Data.Functor.Classes.Ord1 f, GHC.Classes.Ord a) => GHC.Classes.Ord (Data.Functor.Yoneda.Yoneda f a)
instance Data.Functor.Plus.Plus f => Data.Functor.Plus.Plus (Data.Functor.Yoneda.Yoneda f)
instance (Data.Functor.Classes.Read1 f, GHC.Internal.Base.Functor f) => Data.Functor.Classes.Read1 (Data.Functor.Yoneda.Yoneda f)
instance (GHC.Internal.Base.Functor f, GHC.Internal.Read.Read (f a)) => GHC.Internal.Read.Read (Data.Functor.Yoneda.Yoneda f a)
instance Data.Functor.Rep.Representable g => Data.Functor.Rep.Representable (Data.Functor.Yoneda.Yoneda g)
instance Data.Functor.Classes.Show1 f => Data.Functor.Classes.Show1 (Data.Functor.Yoneda.Yoneda f)
instance GHC.Internal.Show.Show (f a) => GHC.Internal.Show.Show (Data.Functor.Yoneda.Yoneda f a)
instance Data.Semigroup.Traversable.Class.Traversable1 f => Data.Semigroup.Traversable.Class.Traversable1 (Data.Functor.Yoneda.Yoneda f)
instance GHC.Internal.Data.Traversable.Traversable f => GHC.Internal.Data.Traversable.Traversable (Data.Functor.Yoneda.Yoneda f)
