module Cat.Functor.Constant where

Constant functorsπŸ”—

A constant functor is a functor that sends every object of to a single object and every morphism of to the identity morphism.

Equivalently, constant functors are factorizations through the terminal category. We opt to take this notion as primitive for ergonomic reasons: it is useful to only be able to write constant functors in a single way.

  Const : D.Ob β†’ Functor C D
  Const X = !Const X F∘ !F

Natural transformations between constant functors are given by a single morphism, and natural isomorphisms by a single iso.

  constⁿ
    : {X Y : D.Ob}
    β†’ D.Hom X Y
    β†’ Const X => Const Y
  constⁿ f = !constⁿ f β—‚ !F

  const-isoⁿ
    : {X Y : D.Ob}
    β†’ X D.β‰… Y
    β†’ Const X ≅ⁿ Const Y
  const-isoⁿ f =
    isoβ†’isoⁿ (Ξ» _ β†’ f) (Ξ» f β†’ D.id-comm-sym)

Essentially constant functorsπŸ”—

A functor is essentially constant if it is (merely) isomorphic to a constant functor.

  is-essentially-constant : Functor C D β†’ Type _
  is-essentially-constant F = βˆƒ[ X ∈ D.Ob ] (F ≅ⁿ Const X)

Essentially constant functors are closed under pre and postcomposition by arbitrary functors.

  essentially-constant-∘l
    : is-essentially-constant F
    β†’ is-essentially-constant (F F∘ G)
  essentially-constant-∘l =
    rec! Ξ» d f β†’
      pure $ d ,
        isoβ†’isoⁿ
          (Ξ» b β†’ isoⁿ→iso f (G.β‚€ b))
          (Ξ» g β†’ sym (f .to .is-natural _ _ (G.₁ g)))

  essentially-constant-∘r
    : is-essentially-constant G
    β†’ is-essentially-constant (F F∘ G)
  essentially-constant-∘r =
    rec! Ξ» c f β†’
      pure $ F.β‚€ c ,
        isoβ†’isoⁿ
          (Ξ» b β†’ F-map-iso F (isoⁿ→iso f b))
          (Ξ» g β†’
            apβ‚‚ D._∘_ (sym (F.F-id)) refl
            βˆ™ F.weave (sym (f .to .is-natural _ _ g)))