constructive mathematics, realizability, computability
propositions as types, proofs as programs, computational trinitarianism
internalization and categorical algebra
algebra object (associative, Lie, …)
natural deduction metalanguage, practical foundations
type theory (dependent, intensional, observational type theory, homotopy type theory)
computational trinitarianism =
propositions as types +programs as proofs +relation type theory/category theory
In a category with internal homs , given an object , the continuation monad is the endofunctor , together with the unit
and multiplication
In general mathematics this monad is ubiquitous as modelling double dualization (cf. Ex. , Ex. and Rem. below).
In computer science this monad is used to model continuation-passing style of programming, and therefore this is also called the continuation monad. The idea here is that a morphism in the Kleisli category of the continuation monad, hence a morphism in the original category of the form , is much like a map from to only that instead of “returning” its output directly it instead feeds it into a given function which hence continues the computation.
(setting) Throughout, denotes a symmetric closed monoidal category, with internal hom , evaluation map , and symmetry . The main example is a cartesian closed category such as Set, where .
We fix an object
and refer to it as the answer object (or answer type, or result type, in computer science). Morphisms , hence (generalized) elements , are called continuations for .
(-notation) We denote morphisms by terms of the simply typed lambda calculus (in the cartesian case) or of the linear -calculus (in the general symmetric monoidal case), interpreted in as its internal language:
a term of type in a context of variables denotes a morphism ;
application, for and , denotes the evaluation map, ;
abstraction denotes the adjunct (“currying”) of the morphism denoted by ;
for terms and in disjoint contexts, denotes their tensor product, a term of type ; and a morphism out of a tensor product is specified by a term in context , written as . (In the cartesian case, is just the pair .)
By the universal property of the internal hom, these terms satisfy -reduction and -reduction .
In the cartesian case this is equivalently the usual notation in terms of generalized elements. In the general symmetric monoidal case it is legitimate here because all terms below use each variable — whether bound or free in the context — exactly once (Rem. ).
We also write .
(dualization is self-adjoint on the right) The functor of dualization into ,
is right adjoint to its own opposite functor:
The hom-isomorphism of this adjunction is the composite of natural isomorphisms
which in -notation (Rem. ) is “swapping the arguments”:
This bijection is its own inverse: .
Each of the displayed bijections is natural in and in ; the outer two by the definition of the internal hom, and the middle one by naturality of the symmetry. That the composite is an involution follows from , or directly from the -formula.
(unit and counit) The adjunction unit of Prop. at is the image of under the hom-isomorphism, which is the canonical map into the double dual:
namely the adjunct of .
Since the hom-isomorphism is its own inverse, the adjunction counit at is, regarded as a morphism in , the same kind of map, namely . Accordingly, both triangle identities of the adjunction reduce to one and the same identity in , saying that the single dual is a retract of the triple dual:
In -notation:
(continuation monad) The continuation monad (or double dualization monad) on with answer object is the monad induced by the adjunction of Prop. , hence with
Explicitly, the components are as follows:
The underlying endofunctor is
hence for :
The unit is the canonical map into the double dual (Rem. ):
The multiplication is the dual of the unit at :
hence it is given by precomposition with ,
which in -notation reads:
(unwinding the multiplication) In the -term for in Def. the subterms have the following types:
In words: is the functional on continuations which, given a continuation , evaluates on the “evaluation at ”-functional
hence:
(monad laws) The data in Def. satisfies the monad axioms.
Abstractly, this is a special case of the general fact that every adjunction induces a monad .
Concretely, in terms of the one triangle identity from Rem. , of the contravariant functoriality and of naturality of :
Left unit law. By the triangle identity for :
Right unit law. By the triangle identity for :
Associativity. We have
and these agree: since , the equation is the naturality square of on the morphism .
Alternatively, in -notation, using only - and -reduction (for associativity, both sides reduce to the same term):
This completes the argument.
(linearity and the role of the symmetry) In each of the -terms on this page every variable, whether bound or free in the context, occurs exactly once. Therefore these terms make sense in the internal linear type theory of any symmetric closed monoidal category: they use neither duplication nor deletion of variables, which is why the definition does not require to be cartesian (see Melliès & Tabareau 2007).
On the other hand, the symmetry is used, if implicitly: it is the exchange rule which allows to form in the context , as in the definition of . In a non-symmetric biclosed monoidal category, writing for the right adjoint of and for that of , the hom-isomorphism of Prop. is instead
so that one has to alternate between the two one-sided internal homs: .
(Kleisli triple / bind form) In terms of Kleisli extension, the continuation monad (Def. ) is given by the unit together with the operation which sends a Kleisli morphism to
Conversely, the multiplication and the functor are recovered as
and the composite of Kleisli morphisms and is
This is the form in which the continuation monad appears in Moggi (1991), Ex. 1.1. In Haskell-notation (ignoring that the standard libraries define Cont r as ContT r Identity, with ContT a newtype):
type Cont r a = (a -> r) -> r
return x = \k -> k x -- unit
m >>= f = \k -> m (\x -> f x k) -- Kleisli extension
join mm = \k -> mm (\m -> m k) -- multiplication
(Kleisli morphisms as continuation transformers) Under the hom-isomorphism of Prop. , Kleisli morphisms correspond to morphisms
which turn continuations of the output into continuations of the input. This correspondence is compatible with composition, in that
Hence the Kleisli category of the continuation monad is equivalent to the opposite of the full subcategory of on the objects of the form , via and . (This is an instance of the general fact that the Kleisli category of the monad induced by an adjunction is equivalent to the full image of the left adjoint.)
In these terms, Kleisli extension and multiplication are just dualization of continuation transformers:
(as a codensity monad) The continuation monad is the (-enriched) codensity monad of the functor which picks the object , since the right Kan extension of along itself is the cotensor
For Set this is the familiar .
Codensity monads of inclusions of full subcategories of “small” objects are closely related: the codensity monad of FinSet Set is the ultrafilter monad, which is a submonad of the continuation monad on with (Ex. ); and the codensity monad of the inclusion of finite-dimensional vector spaces into all vector spaces is the continuation monad of Ex. itself (see Leinster (2013)).
(strength) The continuation monad is a strong monad, with tensorial strength
equivalently (Kock (1972)) it is a -enriched monad, with action on internal homs
(non-commutativity) The continuation monad is (in general) not a commutative monad: The two maps induced by the strength and its mirror image are
which differ in the order in which and get to act on the continuation (“evaluation order”). For example, in Set with and , let and be the constant functionals with value and , respectively: then the first map gives the constant functional with value , the second the one with value .
(double powerset) For Set and , identify maps with subsets (via their characteristic functions). Then is the set of families of subsets of , and the structure maps of Def. become:
Elements of may be thought of as generalized quantifiers on , for instance and , while is the principal ultrafilter at (“evaluation at ”).
Restricting to upward closed families, to filters, or to ultrafilters yields submonads, the last one being the ultrafilter monad, whose algebras are the compact Hausdorff spaces (see Leinster (2013) and Rem. below).
(double dual vector spaces) For the category of vector spaces over a field , with the tensor product of vector spaces, and with the ground field, the continuation monad is
with the canonical map of a vector space into its double dual (which is injective by the existence of bases, invoking the axiom of choice for infinite-dimensional ), and with multiplication
the dual linear map of the canonical inclusion (as in Def. ). This is an example where is not cartesian (cf. Rem. ). On finite-dimensional vector spaces the unit is an isomorphism.
(Stone-Čech compactification)
The Stone-Čech compactification functor is the universal way to map a topological space into a compact Hausdorff space, and it is a form of double dualization into the unit interval , which is a cogenerator in the category of compact Hausdorff spaces (by Urysohn's lemma): For any topological space , is homeomorphic to the closure of the image of the map
into the product topological space of copies of indexed by the set of continuous functions — this map being the evident analog of the unit (Def. ), with the internal hom replaced by the set of continuous functions.
Composing with the inclusion functor yields a monad on .
To a topologist this monad is not an instance of the continuation monad of Def. because:
However the definition does not require the category to be cartesian closed. Top is a symmetric monoidal closed category under the tensor product topology: take the largest topology on the product set of and such that all the constant graph functions are continuous, and endow the hom sets with the smallest topology such that the point evaluation functions are continuous. With these constructions the evaluation function is continuous. Using that topology the Stone-Cech compactification monad is the double dualization monad into the unit interval, i.e., define as the double dual into the unit interval.
Note that then is the codensity monad of the inclusion (as for the codensity monad of any right adjoint, see Leinster (2013)), in line with Rem. . Computing the right Kan extension of the inclusion functor along itself one obtains the double dualization monad on Top. (Use the fact that, on compact Haussdorf spaces, the double dual into the unit interval is an isomorphism.)
Further examples are discussed at:
(monadicity of dualization over ) On the category of sets, the functor is monadic (with left adjoint ) whenever .
(cf. Hyland, Levy, Plotkin & Power 2007 Prop. 10)
The following argument uses classical logic, for instance in identifying the subobject classifier of with the boolean domain .
Since has the left adjoint (Prop. ) and has reflexive coequalizers (these being the coreflexive equalizers in ), by Beck’s crude monadicity theorem it suffices to see that
preserves reflexive coequalizers, hence takes coreflexive equalizers in to coequalizers in ,
reflects isomorphisms.
(The alternative argument of Hyland, Levy, Plotkin & Power 2007, Prop. 10, shows and uses that the image under of a coreflexive equalizer is a split coequalizer.)
Regarding the first point: Say that is (internally) injective if takes coreflexive equalizers in to coequalizers in . (The coreflexivity cannot be dropped here: For example, the equalizer of the identity and of the swap map on is , but the coequalizer of and on the 4-element set has 3 elements, while has a single element.)
The subobject classifier is injective in this sense, by the proof of Paré’s theorem (for constructing finite colimits in an elementary topos), which shows that the power object functor takes coreflexive equalizers to (split) coequalizers. Since preserves connected limits such as equalizers (and, as does any functor, coreflexive pairs), it follows that takes coreflexive equalizers to coequalizers, i.e., that is injective, for any . Finally, for , is a retract of — via the map and the map which sends singletons to their element and all other subsets to a fixed element — so that the functor is a retract of ; and since a retract of a coequalizer diagram is again a coequalizer diagram, also is injective.
Regarding the second point: Since , the set is a retract of ; and since is a cogenerator in , so is , which means that is faithful. But faithful functors reflect monomorphisms and epimorphisms, and in every morphism which is both is an isomorphism. Hence reflects isomorphisms.
(algebras as complete atomic Boolean algebras) Thus, for , the Eilenberg-Moore algebras of the continuation monad on are equivalent to complete atomic Boolean algebras, as the category of these is equivalent to the opposite of the category of sets. (For the continuation monad degenerates: For it is constant on the point, while for it sends to itself and every other set to the point.)
(monadic in multiple ways) This illustrates the fact that a category can be monadic over in multiple ways. In other words, one should not refer to a category as monadic over , unless everyone agrees to which “forgetful functor” is being considered – better is to refer to a functor as monadic.
As a monad in mathematics:
Anders Kock: On double dualization monads, Math. Scand. 27 (1970) 151–165 [jstor:24489892, eudml:166154, pdf]
Anders Kock, Strong functors and monoidal monads, Archiv der Mathematik 23 (1972) 113-120 [doi:10.1007/BF01304852]
As a monad in computer science:
Eugenio Moggi, Ex. 1.1 in: Notions of computation and monads, Information and Computation 93 1 (1991) 55-92 [doi:10.1016/0890-5401(91)90052-4, pdf]
Bartosz Milewski, §21.2.7 in: Category Theory for Programmers, Blurb (2019) [pdf, github, webpage, ISBN:9780464243878]
Tarmo Uustalu, p.27 of: Monads and Interaction Lecture 1 [pdf, pdf], lecture notes for MGS 2021 (2021)
As a codensity monad:
In the generality of linear type theory as the linear double negation monad:
Paul-André Melliès, Nicolas Tabareau: Linear continuations and duality, preprint (2007) [hal:hal-00339156, pdf]
Paul-André Melliès, The parametric continuation monad, Mathematical Structures in Computer Science 27 5 (2017) 651-680, Festschrift in honor of Corrado Böhm for his 90th birthday [doi:10.1017/S0960129515000328, pdf]
The characterization of algebras over the continuation monad:
A characterisation of (enriched) monads isomorphic to continuation monads is given in:
Last revised on October 21, 2026 at 00:11:00. See the history of this page for a list of all contributions to it.