Constant functor (category theory)

For categories 𝐂 and 𝐃, and 𝐃-object R, there is the constant functor ConstR:𝐂→𝐃, defined by

\begin{gather*} \text{Const}_R \; (A \xrightarrow{f} B) = R \xrightarrow{\id_R} R. \end{gather*} ParseError: Function "\id" is not trusted at position 74: …R \xrightarrow{\Μ²iΜ²dΜ²_R} R. \end{gat…

The constant functor sees application in Haskell, especially in particularly type-tricky projects such as lens, where the constant functor powers getters.

  newtype Const r a = MkConst r

  instance Functor (Const r) where
    fmap f (MkConst x) = MkConst x