module Cat.Functor.Closed where

When taken as a (bi)category, the collection of (pre)categories is, in a suitably weak sense, Cartesian closed: there is an equivalence between the functor categories and We do not define the full equivalence here, leaving the natural isomorphisms aside and focusing on the inverse functors themselves: Curry and Uncurry.

The two conversion functions act on objects essentially in the same way as currying and uncurrying behave on functions: the difference is that we must properly stage the action on morphisms. Currying a functor fixes a morphism and we must show that is natural in It follows from a bit of calculation using the functoriality of

Curry : Functor (C Γ—αΆœ D) E β†’ Bifunctor C D E
Curry {C = C} {D = D} F =
  make-bifunctor Ξ» where
    .Fβ‚€ a x  β†’ F.β‚€ (a , x)
    .lmap f  β†’ F.₁ (f , D.id)
    .rmap g  β†’ F.₁ (C.id , g)
    .lmap-id β†’ F.F-id
    .rmap-id β†’ F.F-id
    .lmap-∘ f g β†’ ap F.₁ (refl ,β‚š sym (D.idr _)) βˆ™ F.F-∘ _ _
    .rmap-∘ f g β†’ ap F.₁ (sym (C.idr _) ,β‚š refl) βˆ™ F.F-∘ _ _
    .lrmap  f g β†’ Fr.weave F (C.idr _ βˆ™ sym (C.idl _) ,β‚š D.idl _ βˆ™ sym (D.idr _))
  where
    module C = Precategory C
    module D = Precategory D
    module F = Functor F
open _=>_
evF : Bifunctor (Cat[ C , D ]) C D
evF {C = C} {D = D} = make-bifunctor record where
  module C = Cr C
  module D = Cr D
  Fβ‚€ F x = F .Fβ‚€ x

  lmap     f = f .Ξ· _
  lmap-id    = refl
  lmap-∘ f g = refl

  rmap    {a = F}   f = F .F₁ f
  rmap-id {a = F}     = F .F-id
  rmap-∘  {a = F} _ _ = F .F-∘ _ _

  lrmap f g = f .is-natural _ _ _

eval-at : ⌞ C ⌟ β†’ Functor Cat[ C , D ] D
eval-at {C = C} {D = D} = Bifunctor.Left evF