I know that the Applicative
class is described in category theory as a "lax monoidal functor" but I've never heard the term "lax" before, and the nlab
page on lax functor a bunch of stuff I don't recognize at all, re: bicategories and things that I didn't know we cared about in Haskell. If it is actually about bicategories, can someone give me a plebian view of what that means? Otherwise, what is "lax" doing in this name?
19
votes
Wrong nlab page. See this ncatlab.org/nlab/show/monoidal+functor
– n. 1.8e9-where's-my-share m.
"Lax" as in "Relax" over the constraint of having isomorphic mempty & mappend.
– Pawan Kumar
1 Answers
23
votes
Let's switch to the monoidal view of Applicative
:
unit :: () -> f ()
mult :: (f s, f t) -> f (s, t)
pure :: x -> f x
pure x = fmap (const x) (unit ())
(<*>) :: f (s -> t) -> f s -> f t
ff <*> fs = fmap (uncurry ($)) (mult (ff, fs))
For a strict monoidal functor, unit
and mult
must be isomorphisms. The impact of "lax" is to drop that requirement.
E.g., (up to the usual naivete) (->) a
is strict-monoidal, but []
is only lax-monoidal.