kan-extensions-5.2.7: Kan extensions, Kan lifts, the Yoneda lemma, and (co)density (co)monads

Copyright | (C) 2014-2016 Edward Kmett
License | BSD-style (see the file LICENSE)
Maintainer | Edward Kmett <ekmett@gmail.com>
Stability | provisional
Portability | portable
Safe Haskell | Safe-Inferred
Language | Haskell2010

Data.Functor.Day

Description

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.

http://ncatlab.org/nlab/show/Day+convolution

Synopsis

- data Day (f :: Type -> Type) (g :: Type -> Type) a = Day (f b) (g c) (b -> c -> a)
- day :: f (a -> b) -> g a -> Day f g b
- dap :: Applicative f => Day f f a -> f a
- assoc :: forall (f :: Type -> Type) (g :: Type -> Type) (h :: Type -> Type) a. Day f (Day g h) a -> Day (Day f g) h a
- disassoc :: forall (f :: Type -> Type) (g :: Type -> Type) (h :: Type -> Type) a. Day (Day f g) h a -> Day f (Day g h) a
- swapped :: forall (f :: Type -> Type) (g :: Type -> Type) a. Day f g a -> Day g f a
- intro1 :: f a -> Day Identity f a
- intro2 :: f a -> Day f Identity a
- elim1 :: Functor f => Day Identity f a -> f a
- elim2 :: Functor f => Day f Identity a -> f a
- trans1 :: forall f g (h :: Type -> Type) a. (forall x. f x -> g x) -> Day f h a -> Day g h a
- 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
- 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

# Documentation

data Day (f :: Type -> Type) (g :: Type -> Type) a Source #

The Day convolution of two covariant functors.

Constructors

Day (f b) (g c) (b -> c -> a) |

#### Instances

Instances details

Comonad f => ComonadTrans (Day f) Source # |
Instance details Defined in Data.Functor.Day Methods lower :: Comonad w => Day f w a -> w a Source #
(Representable f, Representable g) => Representable (Day f g) Source # |

Instance details

Defined in Data.Functor.Day

Associated Types

type Rep (Day f g) |
Instance details Defined in Data.Functor.Day type Rep (Day f g) = (Rep f, Rep g)

Methods

tabulate :: (Rep (Day f g) -> a) -> Day f g a Source #

index :: Day f g a -> Rep (Day f g) -> a Source #

(Comonad f, Comonad g) => Comonad (Day f g) Source # |
Instance details Defined in Data.Functor.Day Methods extract :: Day f g a -> a Source # duplicate :: Day f g a -> Day f g (Day f g a) Source # extend :: (Day f g a -> b) -> Day f g a -> Day f g b Source #
(ComonadApply f, ComonadApply g) => ComonadApply (Day f g) Source # |
Instance details Defined in Data.Functor.Day Methods (<@>) :: Day f g (a -> b) -> Day f g a -> Day f g b Source # (@>) :: Day f g a -> Day f g b -> Day f g b Source # (<@) :: Day f g a -> Day f g b -> Day f g a Source #
(Representable f, Representable g) => Distributive (Day f g) Source # |
Instance details Defined in Data.Functor.Day Methods distribute :: Functor f0 => f0 (Day f g a) -> Day f g (f0 a) Source # collect :: Functor f0 => (a -> Day f g b) -> f0 a -> Day f g (f0 b) Source # distributeM :: Monad m => m (Day f g a) -> Day f g (m a) Source # collectM :: Monad m => (a -> Day f g b) -> m a -> Day f g (m b) Source #
(Applicative f, Applicative g) => Applicative (Day f g) Source # |
Instance details Defined in Data.Functor.Day Methods pure :: a -> Day f g a Source # (<*>) :: Day f g (a -> b) -> Day f g a -> Day f g b Source # liftA2 :: (a -> b -> c) -> Day f g a -> Day f g b -> Day f g c Source # (*>) :: Day f g a -> Day f g b -> Day f g b Source # (<*) :: Day f g a -> Day f g b -> Day f g a Source #
Functor (Day f g) Source # |
Instance details Defined in Data.Functor.Day Methods fmap :: (a -> b) -> Day f g a -> Day f g b Source # (<$) :: a -> Day f g b -> Day f g a Source #
(Adjunction f u, Adjunction f' u') => Adjunction (Day f f') (Day u u') Source # |
Instance details Defined in Data.Functor.Day Methods unit :: a -> Day u u' (Day f f' a) Source # counit :: Day f f' (Day u u' a) -> a Source # leftAdjunct :: (Day f f' a -> b) -> a -> Day u u' b Source # rightAdjunct :: (a -> Day u u' b) -> Day f f' a -> b Source #
type Rep (Day f g) Source # |
Instance details Defined in Data.Functor.Day type Rep (Day f g) = (Rep f, Rep g)

day :: f (a -> b) -> g a -> Day f g b Source #

Construct the Day convolution

dap :: Applicative f => Day f f a -> f a Source #

Collapse via a monoidal functor.

    dap (day f g) = f <*> g

assoc :: forall (f :: Type -> Type) (g :: Type -> Type) (h :: Type -> Type) a. Day f (Day g h) a -> Day (Day f g) h a Source #

Day convolution provides a monoidal product. The associativity of this monoid is witnessed by `assoc` and `disassoc`.

    assoc . disassoc = id
    disassoc . assoc = id
    fmap f . assoc = assoc . fmap f

disassoc :: forall (f :: Type -> Type) (g :: Type -> Type) (h :: Type -> Type) a. Day (Day f g) h a -> Day f (Day g h) a Source #

Day convolution provides a monoidal product. The associativity of this monoid is witnessed by `assoc` and `disassoc`.

    assoc . disassoc = id
    disassoc . assoc = id
    fmap f . disassoc = disassoc . fmap f

swapped :: forall (f :: Type -> Type) (g :: Type -> Type) a. Day f g a -> Day g f a Source #

The monoid for `Day` convolution on the cartesian monoidal structure is symmetric.

    fmap f . swapped = swapped . fmap f

intro1 :: f a -> Day Identity f a Source #

`Identity` is the unit of `Day` convolution

    intro1 . elim1 = id
    elim1 . intro1 = id

intro2 :: f a -> Day f Identity a Source #

`Identity` is the unit of `Day` convolution

    intro2 . elim2 = id
    elim2 . intro2 = id

elim1 :: Functor f => Day Identity f a -> f a Source #

`Identity` is the unit of `Day` convolution

    intro1 . elim1 = id
    elim1 . intro1 = id

elim2 :: Functor f => Day f Identity a -> f a Source #

`Identity` is the unit of `Day` convolution

    intro2 . elim2 = id
    elim2 . intro2 = id

trans1 :: forall f g (h :: Type -> Type) a. (forall x. f x -> g x) -> Day f h a -> Day g h a Source #

Apply a natural transformation to the left-hand side of a Day convolution.

This respects the naturality of the natural transformation you supplied:

    fmap f . trans1 fg = trans1 fg . fmap f

trans2 :: forall g h (f :: Type -> Type) a. (forall x. g x -> h x) -> Day f g a -> Day f h a Source #

Apply a natural transformation to the right-hand side of a Day convolution.

This respects the naturality of the natural transformation you supplied:

    fmap f . trans2 fg = trans2 fg . fmap f

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 Source #

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 Source #

Proposition 4.1 from Pastro and Street