Constructing Applicative Functors
Constructing Applicative Functors
This version of the publication may differ from the final published
version.
Ross Paterson
1 Introduction
This paper is part of a tradition of applying elementary category theory to the
design of program libraries. Moggi [16] showed that the notion of monad could be
used to structure denotational descriptions of programming languages, an idea
carried over to program libraries by Wadler [20]. It turns out that the monads
useful in semantics and programming can be constructed from a small number
of monad transformers also identified by Moggi [17].
Applicative functors [15] provide a more limited interface than monads, but
in return have more instances. All monads give rise to applicative functors,
but our aim is to explore the space of additional instances with applications
to programming. We are particularly interested in general constructions, with
which programmers can build their own applicative functors, knowing that they
satisfy the required laws. It is already known that applicative functors, unlike
monads, can be freely composed. We identify a number of further general con-
structions, namely final fixed points, a limited sum construction, a generalization
of semi-direct products of monoids, and coends (including left Kan extensions).
By combining these constructions, one can obtain most of the computational
applicative functors in the literature, with proofs of their laws. General con-
structions also clarify the relationships between seemingly unrelated examples,
and suggest further applications.
Elementary category theory provides an appropriately abstract setting for the
level of generality we seek. An idealized functional language corresponds to a type
of category with first-class functions (a cartesian closed category). Applicative
functors on such a category are equivalent to a simpler form called lax monoidal
2 Ross Paterson
functors, which are more convenient to work with. We can build up lax monoidal
functors in more general ways by ranging across several different categories, as
long as the end result acts on the category of our functional language, and is
thus applicative. Familiarity with the basic definitions of categories and functors
is assumed. The other notions used are mostly shallow, and will be explained
along the way.
In the next section, we introduce applicative and lax monoidal functors. The
rest of the paper describes the general constructions, illustrated with examples in
Haskell where possible. Two proof styles are used throughout the paper. When
making statements that apply to any category, we use standard commuting
diagrams. However many statements assume a cartesian closed category, or at
least a category with products. For these we use the internal language of the
category, which provides a term language with equational reasoning that will be
familiar to functional programmers.
2 Applicative Functors
The categorical notion of “functor” is modelled in Haskell with the type class
class Functor f where
fmap :: (a -> b) -> f a -> f b
Instances include a variety of computational concepts, including containers, in
which fmap modifies elements while preserving shape. Another class of instances
are “notions of computation”, including both monads and applicative functors,
in which terms of type F a correspond to computations producing values of type
a, but also having an “effect” described by the functor F , e.g. modifying a state,
possibly throwing an exception, or non-determinism. The requirement that F be
a functor allows one to modify the value returned without changing the effect.
The applicative interface adds pure computations (having no effect) and an
operation to sequence computations, combining their results. It is described by
a type class:
class Functor f => Applicative f where
pure :: a -> f a
(<*>) :: f (a -> b) -> f a -> f b
If we compare this with the type class of monads:
class Monad m where
return :: a -> m a
(>>=) :: m a -> (a -> m b) -> m b
we see that pure corresponds to return; the difference lies in the sequencing
operations. The more powerful >>= operation available with monads allows the
choice of the second computation to depend on the result of the first, while in
the applicative case there can be no such dependency. Every monad can be made
an applicative functor in a uniform way, here illustrated with the Maybe monad:
Constructing Applicative Functors 3
The more limited applicative interface has many more instances, some of which
will be presented in later sections. For example, the constrained form of sequenc-
ing offered by the applicative interface makes possible instances in which part
of the value is independent of the results of computations, e.g. parsers that pre-
generate parse tables [18]. Unlike monads, applicative functors are closed under
composition.
However many applications of monads, such as traversal of containers, can
be generalized to the applicative interface [15].
unit = pure ()
mult a b = fmap (,) a <*> b
4 Ross Paterson
>⊗F a
λ /Fa F a⊗>
ρ
/Fa
O O
u⊗F a Fλ F a⊗u Fρ
F >⊗F a / F (> ⊗ a) F a⊗F > / F (a ⊗ >)
~ ~
F a ⊗ (F b ⊗ F c)
F a⊗~
/ F a ⊗ F (b ⊗ c) ~
/ F (a ⊗ (b ⊗ c))
α Fα
(F a ⊗ F b) ⊗ F c / F (a ⊗ b) ⊗ F c / F ((a ⊗ b) ⊗ c)
~⊗F c ~
Constructing Applicative Functors 5
The first two diagrams state that u is the left and right identity respectively of
the binary operation ~, while the last diagram expresses the associativity of ~.
Although the definition of a lax monoidal functor neatly generalizes the Monoidal
class, it lacks the counterpart of pure. We will also want an associated axiom stat-
ing that pure computations can be commuted with other computations. (There
is a notion of symmetric lax monoidal functor, but requiring the ability to swap
any two computations would exclude too many functors useful in computation,
where the order in which effects occur is often significant.)
Thus we define an applicative functor on a symmetric monoidal category C
as consisting of a lax monoidal functor F : C → C, with a natural transformation
p : a → F a (corresponding to the pure function of the Applicative class)
satisfying p> = u and p ◦ ~ = ~ ◦ p ⊗ p, plus a weak commutativity condition:
a⊗F b
p⊗F b
/ F a⊗F b ~
/ F (a ⊗ b)
σ Fσ
F b⊗a / F b⊗F a / F (b ⊗ a)
F b⊗p ~
p x = F (const x) u
6 Ross Paterson
F σ (p x ~ y) = F σ (F (const x) u ~ y) definition of p
= F (σ ◦ (const x) × id ) (u ~ y) naturality of ~
= F (σ ◦ (const x) × id ) (F λ−1 y) left identity
= F (id × (const x) ◦ σ) (F λ−1 y) naturality of σ
= F (id × (const x) ◦ σ ◦ λ−1 ) y functor
= F (id × (const x) ◦ ρ−1 ) y symmetry
= F (id × const x) (F ρ−1 y) functor
= F (id × const x) (y ~ u) right identity
= y ~ F (const x) u naturality of ~
= y ~ px definition of p
It is also known that lax monoidal functors in a ccc are equivalent to closed func-
tors [5], which resemble the Applicative interface, but again the lax monoidal
form is more convenient for defining derived functors.
Thus our strategy will be to construct a lax monoidal functor over the product
structure of a ccc, but we may construct it from constituents involving other
monoidal categories. As a simple example, we have seen that the product functor
× : A×A → A is lax monoidal, and we can compose it with the diagonal functor
from A to A × A (also lax monoidal) to obtain a lax monoidal functor from A
to A:
F a=a×a
though in this case the resulting functor is also monadic. In Section 5 we also
use auxiliary categories with monoidal structures other than products.
It turns out that this instance, and the proof that it satisfies the lax monoidal
laws, follow from a general construction. We can observe that ZipList is a fixed
point through the second argument of the binary functor F (a, b) = 1 + a × b.
That is, F is the functor Maybe ◦ ×, a composition of two lax monoidal functors
and therefore lax monoidal.
There are two canonical notions of the fixed point of a functor, the initial and
final fixed points, also known as data and codata. Initial fixed points can be used
to define monads; here we use final fixed points to define lax monoidal functors.
Recall that a parameterized final fixed point of a functor F : A × B → B consists
of a functor νF : A → B with an isomorphism c : F (a, νF a) ∼ = νF a and an
unfold operator [(·)] constructing the unique morphism satisfying
[(f )]
b / νF a
O
f c
F (a, b) / F (a, νF a)
F (a,[(f )])
~F
F (a1 ⊗ a2 , νF a1 ⊗ νF a2 ) / F (a1 ⊗ a2 , νF (a1 ⊗ a2 ))
F (a1 ⊗a2 ,~νF )
3.1 Limits
Ignoring the parameter A for the moment, another way to define the final fixed
point of a functor F : B → B starts with the terminal object 1. Using with the
8 Ross Paterson
··· / F3 1 / F2 1 /F1 /1
F 2 !F 1 F !F 1 !F 1
The final fixed point ν F is defined as the limit of this chain, an object with a
commuting family of morphisms (a cone) to the objects of the chain:
νF
" )/
/ F3 1 +/ /, 1
··· F2 1 F1
F 2 !F 1 F !F 1 !F 1
such that any other such cone, say from an object B, can be expressed as a
composition of a unique morphism B → νF and the cone from νF .
This construction is sufficient for final fixed points of regular functors like
ZipList, but for the general case we need to lift the whole thing to the category
Fun(A, B), whose objects are functors A → B, and whose morphisms are natural
transformations. Given a functor Φ on this category, we can repeat the above
construction in the functor category, starting with the constant functor 1:
νΦ
" )/
··· / Φ3 1 Φ2 1 /+ Φ 1 ,/ 1
2 Φ !Φ 1 !Φ 1
Φ !Φ 1
A standard result holds that limits in Fun(A, B) may be constructed from point-
wise limits in B [13, p. 112].
On the way to defining the final fixed point of Φ as a lax monoidal func-
tor, we wish to require that Φ preserve lax monoidal functors. To state this,
we need a specialized notion of natural transformation for lax monoidal func-
tors: a monoidal transformation between lax monoidal functors hF, ~, >i and
.
hF 0 , ~0 , >0 i is a natural transformation h : F → F 0 that preserves the lax
monoidal operations:
> F a⊗F b
h⊗h
/ F0 a ⊗ F0 b
0
u u
~ ~0
} !
F> / F0 > F (a ⊗ b) / F 0 (a ⊗ b)
h h
F
t0
t3
/ F3 (/ /* F1 /+ F0
··· F2
f2 f1 f0
> F a⊗F b
ti ⊗ti
/ Fi a ⊗ Fi b
u ui
~ ~i
} !
F> / Fi > F (a ⊗ b)
ti
/ Fi (a ⊗ b)
ti
These equations imply that u and ~ are mediating morphisms to the limits
in B, and thus uniquely define them. It remains to show that ~ is a natural
transformation, and that u and ~ satisfy the identity and associativity laws. Each
of these four equations is proven in the same way: we show that the two sides
of the equation are equalized by each ti , as a consequence of the corresponding
equation on Fi , and thus, by universality, must be equal. For example, for the
left identity law we have the diagram
>⊗F a
λ /Fa
O
>⊗ti
' w
ti
> ⊗ Fi a
λ / Fi a
O
u⊗F a ui ⊗Fi a Fi λ Fλ
Fi 7 > ⊗ Fi a / Fi (> ⊗ a)
~i f
ti ⊗ti ti
F >⊗F a / F (> ⊗ a)
~
The central panel is the left identity law for Fi , while the four surrounding panels
follow from the definitions of u and ~ and the naturality of λ and ti . Thus the
two morphisms > ⊗ F a → F a on the perimeter of the diagram is equalized by
ti . Since the universality of the limit implies that such a morphism is unique,
they must be equal. We have proven:
Proposition 1. If B is complete, then so is Mon(A, B).
Applying this to the chain of the fixed point construction, we have the im-
mediate corollary that the final fixed point of a higher-order functor Φ on lax
10 Ross Paterson
3.2 Sums
The dual notion, colimits, is not as easily handled. We can construct sums in
special cases, such as adding the identity functor to another lax monoidal functor:
Here pure computations (represented by the identity functor and the constructor
Return) may be combined with mult, but are converted to the other functor if
either computation involves that functor.
Applying this construction to the constant functor yields a form of compu-
tations with exceptions that collects errors instead of failing at the first error [4,
15]:
That is, in a computation mult e1 e2, after a failure in e1, the whole computa-
tion will fail, but not before executing e2 in case it produces errors that should
be reported together with those produced by e1.
The fixed point L ∼ = Lift (I × L) expands to non-empty lists combined with
a “long zip”, in which the shorter list is padded with copies of its last element
to pair with the remaining elements of the longer list, as suggested by Jeremy
Gibbons and Richard Bird1 :
u = C⊥ u⊥
Cj a ~ Ck b = Cjtk (∆j≤jtk a, ∆k≤jtk b)
Naturality of ~ and the identity and associativity laws follow from simple cal-
culations. t
u
For example, there might be a Symbol for numeric literals, in which case the
corresponding String would record the text of the number. Parsers take a list
of tokens and return either an error string or a parsed value together with the
unparsed remainder of the input:
– The type Maybe a indicates whether the phrase can generate the empty
string, and if so provides a default output value.
– The type Map Symbol (Parser a) records which symbols can start the
phrase, and provides for each a corresponding deterministic parser.
The Functor instance for this type follows from the structure of the type:
The idea, then, is to build a value of this type for each phrase of the grammar,
with the following conversion to a deterministic parser:
and identity (1, 0). For example Horner’s Rule for the evaluation of a polynomial
an xn + · · · + a1 x + a0 can be expressed as a fold of such an operation over the list
[(x, a0 ), (x, a1 ), . . . , (x, an )], with the immediate consequence that the calculation
can be performed in parallel (albeit with repeated calculation of the powers of
x).
We shall consider a generalization of the semi-direct product on lax monoidal
functors, requiring
– a lax monoidal functor hF, ~, ui : hA, ⊗, >i → hB, ×, 1i
14 Ross Paterson
∅oq =∅ (1)
(x ⊕ y) o q = (x o q) ⊕ (y o q) (2)
pn∅=∅ (3)
p n (x ⊕ y) = (p n x) ⊕ (p n y) (4)
also satisfying
(p n y) o r = p n (y o r) (5)
Proposition 3. Given the above functors and operations, there is a lax monoidal
functor hH, ~H , uH i : hA, ⊗, >i → hB, ×, 1i defined by
H a = F a × Ga
uH = (u, ∅)
(a, x) ~H (b, y) = (a ~ b, (x o (b, y)) ⊕ ((a, x) n y))
uH n z = z (6)
(p ~H q) n z = p n (q n z) (7)
x o uH = x (8)
x o (q ~H r) = (x o q) o r (9)
t
u
L c = ∃ m. K m → c
That is, u yields an infinite list, and ~ constructs a list of pairs, whose length is
the smaller of the lengths of the arguments. We recognize this functor as another
version of the ZipList functor defined in Section 3. More generally, if M has a
monoidal structure that is a lower semi-lattice, and K (m1 u m2 ) ⊆ K mi , then
the lax monoidal structure on L computes zips on containers.
16 Ross Paterson
The unit operation constructs a scalar, while mult forms the cartesian product
of two arrays:
instance Monoidal MultiArray where
unit = MA (array ((), ()) [((), ())])
mult (MA xs) (MA ys) =
MA (array ((lx, ly), (hx, hy))
[((i, j), (x, y)) | (i, x) <- assocs xs,
(j, y) <- assocs ys])
where
(lx, hx) = bounds xs
(ly, hy) = bounds ys
We could extend multi-dimensional arrays by adding a distinguished position,
i.e. a cursor within the container:
L c = ∃ m. K m × (K m → c)
When two arrays are combined with mult, their cursors are also paired to form
a cursor on the product array.
Another example arises in Elliott’s analysis of fusion [6], where folds are
reified using a type
data FoldL b a = FoldL (a -> b -> a) a
The type constructor FoldL is not a functor, because its argument a occurs
in both the domain and range of function types. Wishing to apply functorial
machinery to these reified folds, Elliott introduced a related type that could be
defined as a functor:
data WithCont z c = forall a. WC (z a) (a -> c)
Constructing Applicative Functors 17
M
K /C
η
=⇒
T
L
A
For our purposes, it will be more convenient to use the standard pointwise
construction of the left Kan extension as a coend, corresponding to existen-
tial quantification in programming languages. For convenience, we assume that
18 Ross Paterson
the category A is cartesian closed, and that C is an A-category [11], i.e. that
the “hom-sets” of C are objects of A, with identity and composition morphisms
satisfying the usual laws. Using the more familiar notation ∃ in place of the in-
tegral sign favoured by category theorists, the left Kan extension of T : M → A
along K : M → C is the functor L : C → A defined by
L c = ∃ m. T m × C (K m, c)
ω (T h x, k) = ω (x, k ◦ K h)
That is, the existentially qualified type m is abstract: we can change the rep-
resentation without affecting the constructed value. The natural transformation
.
η : T → L ◦ K is defined as
η x = ω (x, id )
s : K (a ⊗M b) → K a ⊗C K b
n : K >M → >C
K (> ⊗ a)
s / K>⊗Ka K (a ⊗ >)
s / Ka⊗K>
Kλ n⊗K a Kρ K a⊗n
Kao >⊗Ka Kao ρ
Ka⊗>
λ
Constructing Applicative Functors 19
K (a ⊗ (b ⊗ c))
s / K a ⊗ K (b ⊗ c) K a⊗s
/ K a ⊗ (K b ⊗ K c)
Kα α
K ((a ⊗ b) ⊗ c) / K (a ⊗ b) ⊗ K c / (K a ⊗ K b) ⊗ K c
s s⊗K c
In the special case where the monoidal structure on C is that of products, there is
only one choice for n, namely the unique arrow K > → 1. Moreover in that case
s : K (a ⊗ b) → K a × K b can be broken down into two components: s = hs1 , s2 i.
Proposition 4. If M and C are monoidal and A has finite products, K is colax
monoidal and T is lax monoidal, then L is lax monoidal, with
uL = ω (uT , nK )
ω (x1 , k1 ) ~L ω (x2 , k2 ) = ω (x1 ~T x2 , k1 × k2 ◦ sK )
This is a special case of Proposition 5, which we shall prove in the next
section.
A degenerate example has M as the trivial category with one object and one
morphism, so that T defines a monoid and K selects some object, with si = id .
This describes computations that write output and also read an environment,
but in which the output is independent of the environment:
L c = T × (K → c)
This applicative functor is a composition of two applicative functors that are
also monads, but the composition is not a monad.
Another simple case arises when M is a cartesian category, in which case an
arbitrary functor K : M → C can be made colax monoidal by setting si = K πi .
Thus we obtain the following Haskell version of the left Kan:2
data Lan t k c = forall m. Lan (t m) (k m -> c)
instance (Functor t, Functor k) => Functor (Lan t k) where
fmap f (Lan x k) = Lan x (f . k)
instance (Monoidal t, Functor k) => Monoidal (Lan t k) where
unit = Lan unit (const ())
mult (Lan x1 k1) (Lan x2 k2) =
Lan (mult x1 x2)
(\ y -> (k1 (fmap fst y), k2 (fmap snd y)))
Although this implementation has the form of a general left Kan extension, it is
limited to the Haskell category.
A richer example occurs in the modelling of behaviours of animations using
applicative functors by Matlage and Gill [14]. The basic functor comprises a
function over a closed interval of time, which can be modelled as pairs of times:
2
In fact the Functor instance requires no assumptions about t and k, and in the
Monoidal instance Zip t could replace Monoidal t.
20 Ross Paterson
Now this type can be made monoidal with the following definitions, which pre-
serve the abstraction:
The final functor used by Matlage and Gill can be obtained by adding constant
behaviour using Lift:
Our final example is a generalization of the type used by Baars, Löh and Swier-
stra [3] to construct parsers for permutations of phrases, which we express as
This implementation is too subtle to explain in full detain here, but the Perms
type is essentially an efficient representation of a collection of all the permuta-
tions of a set of elementary parsers (or actions, in other applications). The type
in the original paper is equivalent to restricting our version of the Perms type to
values of the forms Choice (Just x) [] and Choice Nothing bs, allowing a
single elementary parser to be added to the collection at a time. In contrast, the
mult methods allows the interleaving of arbitrary collections of actions, allowing
us to build them in any order.
The functor instances for these two types are straightforward:
Assuming that p is lax monoidal, we will construct instances for Perms p and
Branch p. These types are mutually recursive, but we know that final fixed
points preserve applicative functors.
We define an operator *** as
(***) :: Monoidal f => f (a1 -> b1) -> f (a2 -> b2) ->
f ((a1,a2) -> (b1,b2))
p *** q = fmap (\ (f,g) (x,y) -> (f x, g y)) (mult p q)
The instance for Perms p is constructed from the instance for Branch p as a
generalized semi-direct product, which builds all the interleavings of the two
collections of permutations:
>B
H J
=
M
K /C
η
⇒
T
L
A
We also assume a natural operator
: C(J a, J b) × C(J c, J d) → C(J (a ⊗ c), J (b ⊗ d))
(corresponding to *** above) satisfying unit and associativity laws:
Jλ◦f >=f ◦Jλ
Jρ◦>f =f ◦Jρ
J α ◦ f (g h) = (f g) h ◦ J α
The situation of ordinary left Kan extensions is the special case where J is the
identity functor and is ⊗C . However in general we do not require that be
a functor. The key example of a structure with such an operator is an enriched
premonoidal category, or “arrow” [2, 9].
Proposition 5. If M and B are monoidal, A has finite products, H is colax
monoidal and T is lax monoidal, then F = L ◦ J is lax monoidal, with
F a = ∃ m. T m × (J (H m) → J a)
F f (ω (x, k)) = ω (x, J f ◦ k)
uF = ω (uT , J nH )
ω (x1 , k1 ) ~F ω (x2 , k2 ) = ω (x1 ~T x2 , k1 k2 ◦ J sH )
Instead of proving this directly, we show that the functor G : Mop × M × A
defined by
G (m0 , m, a) = T m × (J (H m0 ) → J a)
is itself lax monoidal, and then use a general result about coends of lax monoidal
functors. To see that G is lax monoidal, we note that T is lax monoidal, so we
only need to show that the second component is. The left identity case is
F λ ◦ id k ◦ J (nH × 1 ◦ sH ) = k ◦ J (λ ◦ nH × 1 ◦ sH ) left identity of
= k ◦ J (H λ) left identity of H
The right identity case is similar. Associativity relies on the associativity of :
J α ◦ k1 (k2 k3 ◦ J sH ) ◦ J sH
= J α ◦ k1 (k2 k3 ) ◦ J (id × sH ◦ sH ) naturality of
= (k1 k2 ) k3 ◦ J (α ◦ id × sH ◦ sH ) associativity of
= (k1 k2 ) k3 ◦ J (sH × id ◦ sH ◦ H α) associativity of sH
Constructing Applicative Functors 23
Thus it suffices to show that coends preserve lax monoidal functors, which is our
final result.
Proposition 6. Given monoidal categories A and B and a ccc C, with a lax
monoidal functor G : Aop × A × B → C, then the coend F b = ∃ a. G (a, a, b) is
also lax monoidal, with
F b = ∃ a. G (a, a, b)
F f (ω x) = ω (G (id , id , f ) x)
uF = ω uG
ω x1 ~F ω x2 = ω (x1 ~G x2 )
Proof. It is a standard result that a parameterized coend such as F defines a
functor. Naturality of ~F follows from naturality of ~G :
F (f1 ⊗ f2 ) (ω x1 ~F ω x2 )
= F (f1 ⊗ f2 ) (ω (x1 ~G x2 )) definition of ~F
= ω (G (id , id , f1 ⊗ f2 ) (x1 ~G x2 )) definition of F
= ω (G (id , id , f1 ) x1 ~G G (id , id , f2 ) x2 ) naturality of ~G
= ω (G (id , id , f1 ) x1 ) ~F ω (G (id , id , f2 ) x2 ) definition of ~F
= F f1 (ω x1 ) ~F F f2 (ω x2 ) definition of F
Similarly the left identity law for F follows from the corresponding law for G:
F λ (uF ~F ω x) = F λ (ω uG ~F ω x) definition of uF
= F λ (ω (uG ~G x)) definition of ~F
= ω (G (id , id , λ) (uG ~G x)) definition of F
= ω (G (id , λ ◦ λ−1 , λ) (uG ~G x)) isomorphism
= ω (G (λ−1 , λ, λ) (uG ~G x)) dinaturality of ω
= ωx left identity of G
The right identity case is similar.
Finally, the associativity law for ~F follows from the associativity of ~G :
F α (ω x ~F (ω y ~F ω z))
= F α (ω x ~F ω (y ~G z)) definition of ~F
= F α (ω (x ~G (y ~G z))) definition of ~F
= ω (G (id , id , α) (x ~G (y ~G z))) definition of F
= ω (G (id , α ◦ α−1 , α) (x ~G (y ~G z))) isomorphism
= ω (G (α−1 , α, α) (x ~G (y ~G z))) dinaturality of ω
= ω ((x ~G y) ~G z) associativity of G
= ω (x ~G y) ~F ω z definition of ~F
= (ω x ~F ω y) ~F ω z definition of ~F
t
u
As a further example, we have the coend encoding of the final fixed point
ν F of a functor F : A × B → B:
νF a∼
= ∃ b. b × (b → F (a, b))
24 Ross Paterson
which is a coend of G (b0 , b, a) = b × (b0 → F (a, b)), and yields the same applica-
tive functor as discussed in Section 3.
6 Conclusion
We have established a number of general constructions of lax monoidal func-
tors, and therefore of applicative functors. In examples such as the permutation
phrases of Section 5.2, we showed that by combining these constructions we could
account for quite complex (and useful) applicative functors, avoiding the need for
specific proofs of their laws. By breaking the functors down into simple building
blocks, we have clarified their relationships, as well providing the tools to build
more applications. The next stage is to examine the possible combinations, and
to consider other constructions.
References
1. Michael Abbott, Thorsten Altenkirch, and Neil Ghani. Categories of containers.
In Andrew D. Gordon, editor, FoSSaCS, volume 2620 of LNCS, pages 23–38, 2003.
2. Robert Atkey. What is a categorical model of arrows? Electronic Notes on Theo-
retical Computer Science, 229(5):19–37, 2011.
3. Arthur I. Baars, Andres Löh, and S. Doaitse Swierstra. Parsing permutation
phrases. Journal of Functional Programming, 14(6):635–646, 2004.
4. Duncan Coutts. Arrows for errors: Extending the error monad, 2002. Unpublished
presentation at the Summer School on Advanced Functional Programming.
5. S. Eilenberg and G.M. Kelly. Closed categories. In S. Eilenberg, D. K. Harrison,
H. Röhrl, and S. MacLane, editors, Proceedings of the Conference on Categorical
Algebra, pages 421–562. Springer, 1966.
6. Conal Elliott. Denotational design with type class morphisms. Technical Report
2009-01, LambdaPix, 2009.
7. Ralf Hinze. Type fusion. In Dusko Pavlovic and Michael Johnson, editors, Pro-
ceedings of the Thirteenth International Conference on Algebraic Methodology And
Software Technology (AMAST ’10), volume 6486 of LNCS, pages 92–110. Springer,
2010.
8. Ralf Hinze. Kan extensions for program optimisation, or: Art and dan explain an
old trick. In Jeremy Gibbons and Pablo Nogueira, editors, Mathematics of Program
Construction, 2012.
9. John Hughes. Generalising monads to arrows. Science of Computer Programming,
37(1–3):67–111, May 2000.
10. Patricia Johann and Neil Ghani. A principled approach to programming with
nested types in Haskell. Higher-Order and Symbolic Computation, 22(2):155–189,
2009.
11. G. M. Kelly. Basic concepts of enriched category theory, volume 64 of London
Mathematical Society Lecture Note Series. Cambridge University Press, 1982.
12. J. Lambek and P. J. Scott. Introduction to Higher Order Categorical Logic. Num-
ber 7 in Cambridge Studies in Advanced Mathematics. Cambridge University
Press, Cambridge, 1986.
13. Saunders Mac Lane. Categories for the Working Mathematician. Springer, New
York, 1971.
Constructing Applicative Functors 25
14. Kevin Matlage and Andy Gill. Every animation should have a beginning, a middle,
and an end: A case study of using a functor-based animation language. In Rex Page,
Zoltán Horváth, and Viktória Zsók, editors, Proceedings of the 11th International
Conference on Trends in Functional Programming, volume 6546 of LNCS, pages
150–165. Springer, 2011.
15. Conor McBride and Ross Paterson. Applicative programming with effects. Journal
of Functional Programming, 18(1):1–13, 2008.
16. Eugenio Moggi. Computational lambda-calculus and monads. In Logic in Com-
puter Science, pages 14–23. IEEE Computer Society Press, 1989.
17. Eugenio Moggi. An abstract view of programming languages. Technical Report
ECS-LFCS-90-113, Laboratory for Foundations of Computer Science, University
of Edinburgh, 1990.
18. S. Doaitse Swierstra and Luc Duponcheel. Deterministic, error-correcting combina-
tor parsers. In John Launchbury, Erik Meijer, and Tim Sheard, editors, Advanced
Functional Programming, volume 1129 of LNCS, pages 184–207. Springer, 1996.
19. Janis Voigtländer. Asymptotic improvement of functions over free monads. In
Philippe Audebaud and Christine Paulin-Mohring, editors, Mathematics of Pro-
gram Construction, volume 5133 of LNCS, pages 388–403. Springer, 2008.
20. Philip Wadler. Comprehending monads. Mathematical Structures in Computer
Science, 2(4):461–493, 1992.