Data.Functor.Contravariant.Day

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

Copyright | (C) 2013-2016 Edward Kmett Gershom Bazerman and Derek Elkins
License | BSD-style (see the file LICENSE)
Maintainer | Edward Kmett <ekmett@gmail.com>
Stability | provisional
Portability | portable
Safe Haskell | None
Language | Haskell2010

Data.Functor.Contravariant.Day

Description

The Day convolution of two contravariant functors is a contravariant functor.

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

Synopsis

- data Day (f :: Type -> Type) (g :: Type -> Type) a = Day (f b) (g c) (a -> (b, c))
- day :: f a -> g b -> Day f g (a, b)
- runDay :: (Contravariant f, Contravariant g) => Day f g a -> (f a, g 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 (Proxy :: Type -> Type) f a
- intro2 :: f a -> Day f (Proxy :: Type -> Type) a
- day1 :: forall f (g :: Type -> Type) a. Contravariant f => Day f g a -> f a
- day2 :: forall g (f :: Type -> Type) a. Contravariant g => Day f g a -> g a
- diag :: f a -> Day f 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

# Documentation

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

The Day convolution of two contravariant functors.

Constructors

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

#### Instances

Instances details

(Representable f, Representable g) => Representable (Day f g) # |
Instance details Defined in Data.Functor.Contravariant.Day Associated Types
type Rep (Day f g) |
Instance details Defined in Data.Functor.Contravariant.Day type Rep (Day f g) = (Rep f, Rep g)
Methods tabulate :: (a -> Rep (Day f g)) -> Day f g a # index :: Day f g a -> a -> Rep (Day f g) # contramapWithRep :: (b -> Either a (Rep (Day f g))) -> Day f g a -> Day f g b #
Contravariant (Day f g) # |
Instance details Defined in Data.Functor.Contravariant.Day Methods contramap :: (a' -> a) -> Day f g a -> Day f g a' # (>$) :: b -> Day f g b -> Day f g a #
(Divisible f, Divisible g) => Divisible (Day f g) # |
Instance details Defined in Data.Functor.Contravariant.Day Methods divide :: (a -> (b, c)) -> Day f g b -> Day f g c -> Day f g a # conquer :: Day f g a #
(Adjunction f u, Adjunction f' u') => Adjunction (Day f f') (Day u u') # |
Instance details Defined in Data.Functor.Contravariant.Day Methods unit :: a -> Day u u' (Day f f' a) # counit :: a -> Day f f' (Day u u' a) # leftAdjunct :: (b -> Day f f' a) -> a -> Day u u' b # rightAdjunct :: (a -> Day u u' b) -> b -> Day f f' a #
type Rep (Day f g) # |
Instance details Defined in Data.Functor.Contravariant.Day type Rep (Day f g) = (Rep f, Rep g)

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

Construct the Day convolution

    day1 (day f g) = f
    day2 (day f g) = g

runDay :: (Contravariant f, Contravariant g) => Day f g a -> (f a, g a) #

Break apart the Day convolution of two contravariant functors.

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 `assoc` and `disassoc`.

    assoc . disassoc = id
    disassoc . assoc = id
    contramap f . assoc = assoc . contramap 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 #

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

    assoc . disassoc = id
    disassoc . assoc = id
    contramap f . disassoc = disassoc . contramap f

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

The monoid for Day convolution in Haskell is symmetric.

    contramap f . swapped = swapped . contramap f

intro1 :: f a -> Day (Proxy :: Type -> Type) f a #

Proxy serves as the unit of Day convolution.

    day1 . intro1 = id
    contramap f . intro1 = intro1 . contramap f

intro2 :: f a -> Day f (Proxy :: Type -> Type) a #

Proxy serves as the unit of Day convolution.

    day2 . intro2 = id
    contramap f . intro2 = intro2 . contramap f

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.

    day1 . intro1 = id
    day1 = fst . runDay
    contramap f . day1 = day1 . contramap f

day2 :: forall g (f :: Type -> Type) a. Contravariant g => Day f g a -> g a #

In Haskell we can do general purpose elimination, but in a more general setting it is only possible to eliminate the unit. ``day2` `.` `intro2` = `id` `day2` = `snd` `.` `runDay` `contramap` f `.` `day2` = `day2` `.` `contramap` f`

diag :: f a -> Day f f a #

Diagonalize the Day convolution:

    day1 . diag = id
    day2 . diag = id
    runDay . diag = a -> (a,a)
    contramap f . diag = diag . contramap f

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 left-hand side of a Day convolution.

This respects the naturality of the natural transformation you supplied:

    contramap f . trans1 fg = trans1 fg . contramap f

trans2 :: forall g h (f :: Type -> Type) a. (forall x. g x -> h x) -> Day f g a -> Day f 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:

    contramap f . trans2 fg = trans2 fg . contramap f