We revisit once again the connection between three notions of computation: monads, arrows and idioms (also called applicative functors). We employ monoidal categories of finitary functors and profunctors on finite sets as models of these notions of computation, and develop the connections between them through adjunctions. As a result, we obtain a categorical version of Lindley, Yallop and Wadler's characterisation of monads and idioms as arrows satisfying an isomorphism.

## Authors

• 4 publications
04/01/2019

### Categories with Families: Unityped, Simply Typed, and Dependently Typed

We show how the categorical logic of untyped, simply typed and dependent...
02/16/2021

### Arboreal Categories: An Axiomatic Theory of Resources

We introduce arboreal categories, which have an intrinsic process struct...
09/29/2017

### On bifibrations of model categories

In this article, we develop a notion of Quillen bifibration which combin...
05/20/2020

### Comprehension and quotient structures in the language of 2-categories

Lawvere observed in his celebrated work on hyperdoctrines that the set-t...
06/29/2020

Game comonads, introduced by Abramsky, Dawar and Wang and developed by A...
08/08/2002

### Linking Makinson and Kraus-Lehmann-Magidor preferential entailments

About ten years ago, various notions of preferential entailment have bee...
10/06/2021

### Data-Centric AI Requires Rethinking Data Notion

The transition towards data-centric AI requires revisiting data notions ...
##### This week in AI

Get the week's most popular data science and artificial intelligence research sent straight to your inbox every Saturday.

## 1 Introduction

The semantic study of computational effects has not only provided tools for reasoning about effectful programs, but also introduced a methodology for organising functional code around fundamental interfaces coming from mathematics. This is the story of monads, which in the beginning were introduced by Moggi to model effectful computations, but soon after that Wadler internalised them in a functional programming language to structure code. In this way, monads became an interface capturing a pattern, which was later expressed as a type-class, and chosen to be the interface for the basic IO mechanism in Haskell. Over time, new interfaces were defined, each one providing different levels of control on how to combine computations. We are interested in two of these interfaces that emerged: arrows and idioms. Arrows were introduced by Hughes [8] and idioms, or applicative functors, by McBride and Paterson [15]. Even when arrows and idioms differ from monads, they still share some basic form. In previous work [20], we gave an unified presentation of these three interfaces in terms of monoids in monoidal categories. In this paper we take a first step in addressing the connection between these interfaces by looking at their monoidal structures and relating them by adjunctions.

Instead of starting from scratch, we build on previous results relating these structures. Ten years ago, in MSFP 2008, Lindley, Yallop and Wadler presented an article connecting idioms, arrows and monads. In a nutshell, we can summarise their result in the following diagram of embeddings

together with the equations

 Idiom =Arrow+(A⇝B≅1⇝(A→B)), (1) Monad =Arrow+(A⇝B≅A→(1⇝B)). (2)

These equations explain how to see idioms and monads as arrows in which a particular isomorphism holds. The method they used to establish these formulas was purely syntactical. Basically, they proposed theories for describing different versions of -calculus with effects, and used a notion of theory translation to show the relations.

This article is a first step towards understanding these equalities from a semantic point of view. In what follows, we deconstruct these characterisations by using the underlying structure of idioms, monads and arrows: functors and strong profunctors.

###### Remark 1.

In order to avoid size issues, we restrict ourselves to modelling the notions of computation by finitary functors, and their profunctor counterpart, which are strong endoprofunctors on finite sets. It should be possible to replace finite sets by a general category together with an inclusion functor into sets, subject to certain conditions, such as density.

Denoting the category of finite sets by and the category of sets by , we aim to express Equations 2 and 1 in terms of functor categories

 [F,S]and[Fop×F,S]s

where denotes the opposite category and the subscript “” represents the restriction to strong profunctors. The idea that we develop in the article follows from the next observation. Given a strong endoprofunctor , we can fix its first parameter and obtain a finitary functor:

 P∗(X)=P(1,X),where 1 denotes the terminal object of F.

Conversely, there are two ways in which a finitary functor might be presented as a strong endoprofunctor on :

 F!(X,Y)=F(X→Y),F∗(X,Y)=X→FY.

Taking (the underlying profunctor of an arrow), we can express the isomorphisms

 A⇝B≅1⇝(A→B),A⇝B≅A→(1⇝B)

simply as the equivalences

 P(A,B)≅P(1,A→B),P(A,B)≅A→P(1,B)

or directly as profunctor equivalences in terms of , and

 P≅(P∗)!,P≅(P∗)∗.

In the following sections, a pair of adjunctions between , and are introduced, and as a result we obtain that the map extends to a comonad and the map extends to a monad. The mentioned adjunctions are monoidal, and thus establish equivalences between the categories of monoids. In this way, we get a first approximation to Lindley et al.’s result from a categorical point of view.

This article might be seen as a continuation of previous articles in the spirit of notions of computation as monoids. The starting point was an article of the author with Jaskelioff [20]. Later, the adjunctions between , and were exploited in the context of non-monadic effect handlers [18], although their relation to the Equations 2 and 1 by using the derived monad/comonad and their corresponding monoidal structure was not treated.

###### Contributions.

The main contributions of this paper are:

• We give a detailed and more mathematical introduction to the adjunctions presented in previous work [18].

• We recognise in these adjunctions the essence of Lindley, Yallop and Wadler’s result from a semantic point of view.

The rest of the article is organised as follows. In Section 2, we review some background material needed to express the adjunctions and relate monoidal structures to arrows, idioms and monads. Then, in Section 3, we present adjunctions between the categories representing effects, and introduce some properties they have. In Section 4 we establish Equations 2 and 1 from a categorical argument, explaining Lindley et al.’s result from a semantic point of view. Finally, in Section 5, we conclude and discuss further work.

## 2 Background

We assume the reader is familiar with basic concepts of category theory, including adjunctions. We briefly introduce some categorical topics we need, such as monoidal categories, partly to be self-contained and partly to fix notations. An exception to this is the use of coends, which are not explained here mainly for brevity reasons. In case the reader is not familiar with them, coends might be (informally) seen as existential or types. The usual reference for all these topics is Mac Lane’s book [14], and a complete reference for (co)ends is Loregian’s notes [13]. An introduction to these topics oriented for the functional programming community might be found in [20]. We try to follow standard categorical notation for most of the text. We denote exponentials by , the evaluation morphism by and the currying of a morphism as . Note that exponentials of coincide with exponentials of and their respective hom-sets, and so we treat them ambiguously.

### 2.1 Implementation of notions of computation

Before starting with the categorical preliminaries, we remind the reader of the basic interfaces we are treating, as in the rest of the text we will not put emphasis on the programming side.

The first interface we are interested in are monads, which are abstracted by the following type-class.

[3] [5][5]return[13][13]::afa[E]
[3] [5][5](¿¿=)[13][13]::fa→(afb)→fb[E]

A monad is a functor (type constructor which is compatible with ) which is endowed with two basic primitives. Reading a term of type as a computation returning a value of type , then the primitive embeds pure values as computations, while (pronounced bind) accounts for the sequencing of computations.

The next interface we will model with monoidal categories is that of applicative functors.

B@¿l¡@3@¿l¡@5@¿l¡@12@¿l¡@E@¿l¡@[3]classFunctorfApplicativefwhere[E]
[3] [5][5]pure[12][12]::afa[E]
[3] [5][5](⊛)[12][12]::f (ab)→fafb[E]

If we flip arguments for the combinator , we see that applicative functors are similar to monads, with the difference that the “following” computation on the combinator cannot depend dynamically on its input parameter .

The third interface we cover is arrows.

B@¿l¡@3@¿l¡@5@¿l¡@12@¿l¡@E@¿l¡@[3]classArrow () where[E]
[3] [5][5]arr[12][12]::(ab)→(ab)[E]
[3] [5][5]()[12][12]::(ab)→(bc)→(ac)[E]
[3] [5][5]first[12][12]::(ab)→((a,c)(b,c))[E]

This interface builds on profunctors rather than on functors. Terms of type are read as computations that ask for input of type and return output of type . Using the combinator, one can construct a computation from a function. The combinator sequences two computations. Finally, the combinator represents the strength of the arrow: it is used to construct computations that operate on an extra parameter without modifying it. The operation is handling the compatibility of the arrow with the cartesian structure.

###### Remark 2.

Morally, one can think that there is nothing corresponding to the operation in the type-classes and because a strength can be obtained for free in the case of functors:

B@¿l¡@E@¿l¡@[B]σ::f abf (a,b)[E]
[B]σ v b=fmap (λa
(a,b)) v[E]

We return later to this point in our discussion of strong profunctors.

### 2.2 Monoidal categories

We recall briefly the basic definitions of monoidal categories. A monoidal category is a category together with a bifunctor , a distinguished object , and natural isomorphisms

 λ:I⊗A≅A,ρ:A⊗I≅A,α:A⊗(B⊗C)≅(A⊗B)⊗C

such that certain coherences hold. The bifunctor is referred to as the tensor, and the distinguished object as the unit. Moreover, we refer to the monoidal category by the triple , omitting , and . When it is clear from the context, we even omit the monoidal structure and just speak of being a monoidal category.

Monoidal categories generalise categories with finite products: the bifunctor is given by the binary product , the unit by the terminal object, and the isomorphisms are defined as

 λ=π2ρ=π1α=⟨⟨π1,π1∘π2⟩,π2∘π2⟩λ−1=⟨!A,id⟩ρ−1=⟨id,!A⟩α−1=⟨π1∘π1,⟨π2∘π1,π2⟩⟩

where is defined by the universal property of products as the unique morphism such that and .

Another popular example of monoidal category is the category of endofunctors on any category . The tensor is defined as composition of functors, and the identity functor is the unit. This a strict monoidal category, i.e. a monoidal category in which the isomorphisms , and are identities.

Following the microcosm principle, the notion of monoid can be defined in any monoidal category . A monoid is a triple where is an object of , and , are morphisms of such that the equations

 λ=m∘(e⊗id),ρ=m∘(id⊗e),m∘(m⊗id)∘α=m∘(id⊗m)

hold. For example, a monoid in is a monoid in the usual mathematical sense, and a monoid in is a monad on . Monoids on a monoidal category form a category, where an morphism from a monoid to a monoid is a morphism such that

 f∘eM=eNandf∘mM=mN∘(f⊗f).

We denote this category by .

Let and be monoidal categories. It is natural to consider functors that are compatible with the monoidal structures. A strong monoidal functor is a triple where is a functor, is an isomorphism and is family of isomorphisms natural in and such that certain coherences hold. If instead of isomorphisms we just consider morphisms, then we have monoidal functors if we ask the morphisms to go from left to right, or opmonoidal functors if the morphisms go from right to left. A monoidal or opmonoidal functor can be normal if the morphism relating the units ( and ) is invertible. We usually omit the monoidal structure from and speak of being a (strong, op)monoidal functor. However, it is important to have in mind that a functor could have different monoidal structures.

### 2.3 Profunctors and their strengths

An endoprofunctor on the category of finite sets is a functor . By fixing arguments, each profunctor on comes with two canonical strengths. If we fix the contravariant argument, we obtain a functor with a strength in the usual sense (see Remark 2), while in the case of fixing the covariant argument, we obtain a strength in the sense of Brady and Trimble [5]. That is, we obtain a contravariant functor with a family of maps

 ςA,B:F(A×B)×A→FB,(v,a)↦F(λz.(a,z))(v)

natural in and , such that certain coherence conditions hold. We denote these two strengths for an endoprofunctor by

 σP:P(X,Y)×Z→P(X×Z,Y),ςP:P(X×Y,Z)×X→P(Y,Z).
###### Remark 3.

Note that such strengths are always available for functors . When we consider these strengths on the component , the strength morphism is actually invertible.

The strengths and are strengths independent in each variable. Alternatively, we might consider strength for endoprofunctors which act on both variables at the same time. This gives the notion of strong endoprofunctor, which is a form of the notion of Tambara module defined by Pastro and Street [17].

###### Definition 1.

A endoprofunctor is said to be (right) strong if it comes equipped with a family of morphisms

 strX,Y,Z:P(X,Y)→P(X×Z,Y×Z)

natural in , and dinatural in such that the equations

 P(id,π1)∘strX,Y,1=P(π1,id), strX,Y,W∘strX,Y,V=P(α−1,α)∘strX,Y,V×W

hold. Since we work with the cartesian monoidal structure, there is no need to define left strong and bistrong endoprofunctors.

Accordingly, a notion of morphism between strong endoprofunctors is defined.

###### Definition 2.

A strong natural transformation from to is a natural transformation such that the equation

 τX×Z,Y×Z∘strPX,Y,Z=strQX,Y,Z∘τX,Y

holds.

Strong endoprofunctors and strong natural transformations between them form a category, which we denote by . There is a forgetful functor

which forgets the strength on a strong endoprofunctor. The functor has left and right adjoints, providing a way to construct free and cofree strong endoprofunctors from an endoprofunctor [20, 17].

### 2.4 Monoidal Structures on Finitary Functors

We have already mentioned that the category of endofunctors forms a monoidal category with composition, and that its monoids are monads. In particular, a monoid in the monoidal category is a monad on . A finitary functor might be seen as a functor by the following construction:

 ¯F(Z)=∫YF(Y)×(i Y→Z)

where denotes the inclusion functor from finite sets to sets.

When we consider a finitary functors, i.e. the category , we obtain an alternative presentation of the composition structure, which is defined by the coend formula

 (F∘G)(X)=∫CF C×(C→GX)

and the unit is given by the inclusion functor . A monoid for this monoidal structure is a finitary monad on , i.e. a finitary functor together with morphisms

 e:i→F,m:F∘F→F

such that certain diagrams commute. The morphism corresponds to the operation in the type-class, while corresponds to the operation .

There is another monoidal structure on finitary functors. As finitary functors are presheaves, they have a canonical monoidal structure given by the Day convolution. The tensor of finitary functors and as objects in might be expressed as

 (F⋆G)(X)=∫CF C×G (C→X),

and the inclusion functor acts again as the unit. A monoid for this monoidal structure is given by a finitary functor together with morphisms

 e:i→F,m:F⋆F→F

such that certain diagrams commute. The morphism represents the operation of an idiom, and represents the combinator .

###### Remark 4.

The categorical presentation of idioms as monoidal functors with a strength is well known [15]. We have chosen a different (but equivalent) presentation for the Day convolution as it is closer to the traditional interface. As the monoidal structure considered is cartesian, both constructions are equivalent.

In contexts where confusion might arise, to distinguish between and without having to mention all the monoidal structure, we simply refer to them as and .

### 2.5 Monoidal Structure on Strong Profunctors

Profunctors in general, and endoprofunctors in particular, can be composed by Bénabou’s tensor, giving rise to a monoidal structure on the category of endoprofunctors . Indeed, this monoidal structure can be lifted to strong endoprofunctors. We make this structure precise in the following definition.

###### Definition 3.

The category has a monoidal structure, with tensor product of and defined as where

 (P⊗Q)(X,Y)=∫WP(X,W)×Q(W,Y),
 str(P⊗Q)X,Y,Z:∫WP(X,W)×Q(W,Y)⟶∫WP(X×Z,W)×Q(W,Y×Z).

The strength is defined by the universal property of coends as the unique morphism such that

 str(P⊗Q)X,Y,Z∘ιW=ιW×Z∘(strPZ×strQZ).

with being the coend injection for . The unit for the monoidal tensor is , where

 strHomX,Y,Z:Hom(X,Y)⟶Hom(X×Z,Y×Z)f⟼f×id

As observed by Jacobs et al. [9], arrows correspond to monoids in this category (disregarding the fact they consider a general category instead of ). A monoid in this category is a strong profunctor together with morphisms

 e:Hom→A,m:A⊗A→A

such that certain diagrams commute. The morphism represents the operation of the arrow, represents sequential composition , and the strength of the profunctor gives the operation.

In what follows, we sometimes refer to a strong profunctor just by , but the reader has to have in mind that a profunctor could have more than one strength, and that we expect natural transformations to be strong.

## 3 The Cayley and Kleisli Adjunctions

The Equations 2 and 1 relate the categories of monoids corresponding to

 [F,S]⋆,[Fop×F,S]s,[F,S]∘.

To obtain this result, we first construct adjunctions between the underlying categories, and then see how they interact with the monoidal structures. The central objects of our adjunctions are strong profunctors, and how they can be recast into a functor. As we explained in the introduction, the contravariant argument of the profunctor might be fixed to the terminal object of , obtaining thus a finitary functor. We capture the re-casting with the functor .

 \raisebox0.4pt−∗:[Fop×F,S]s⟶[F,S]P∗=Z↦P(1,Z)τ∗Z=τ1,Z

The next step is to find left and right adjoints for the re-casting functor. These adjoints might be derived using the left and right Kan extensions [14], although we do a direct presentation in order to minimise the background material.

We begin describing the left adjoint to . This functor was called Cayley in previous work [17, 20, 18]. We now refer to it as , but keep the name Cayley to refer to the adjunction.

###### Theorem 1.

The functor has a left adjoint given by

 \raisebox0.4pt−!:[F,S]⟶[Fop×F,S]sF!=((X,Y)↦F(X→Y),v↦F(⌊(ev×id)∘α⌋)(v))(τ!)X,Y=τX→Y

Moreover, the unit of the adjunction is a natural isomorphism.

###### Proof.

The unit and counit of the adjunction are

 η!F:F Z⟶F!∗ Zη!F=F(⌊ρ⌋)ε!(P,str):P∗!(X,Y)⟶P(X,Y)ε!(P,str)=P(λ−1,ev)∘str

where these definitions are parametric over and respectively. After some calculations, it can be shown that the triangular identities hold. The inverse of the unit is simply defined as . ∎

The right adjoint to is defined by a construction similar to the direct image of a functor. In previous work we have called this functor Kleisli, and therefore we now refer to the resulting adjunction as the Kleisli adjunction.

###### Theorem 2.

The functor has a right adjoint given by

 \raisebox0.4pt−∗:[F,S]⟶[Fop×F,S]sF∗=((X,Y)↦i X→F Y,v↦F(⌊σ∘(ev×id)∘α⌋)(v))(τ∗)X,Y=⌊τY∘ev⌋

Moreover, the counit of the adjunction is a natural isomorphism.

###### Proof.

The unit and counit of the adjunction are

 η∗(P,str):P(X,Y)⟶P∗∗(X,Y)η∗(P,str)=⌊ςP∘P(ρ,id)⌋ε∗F:F∗∗ Z⟶F Zε∗F=ev∘ρ−1

where these definitions are parametric over and respectively.

Again, it is routine to show that the triangular identities hold. The inverse of the counit is . ∎

Summing up, we obtain the following situation, which we depict in a diagram.

The fact that the unit (counit) is invertible can be expressed in a number of equivalent statements. It will prove useful to ave these equivalences around, and so we state the following theorem [7].

###### Theorem 3.

The following statements are equivalent:

• The counit is a natural isomorphism.

• is fully faithful.

Dually, the following are also equivalent:

• The unit is a natural isomorphism.

• is fully faithful.

We can apply Theorem 3 to the adjunctions and , and obtain the following propositions.

###### Proposition 1.

The functor is fully faithful and the comonad is idempotent.

###### Proposition 2.

The functor is fully faithful and the monad is idempotent.

## 4 Equivalences from Monoidal Adjunctions

We now want to relate these adjunctions to the monoidal structures presented in Section 2. The first step is to define natural transformations and adjunctions that are compatible with monoidal structures [2].

###### Definition 4.

Let be monoidal functors. A natural transformation is monoidal if

 τI∘γ0=δ0,τA⊗B∘γA,B=δA,B∘(τA⊕τB).

There is a straightforward dual definition of opmonoidal natural transformations between opmonoidal functors.

###### Definition 5.

An adjunction with unit and counit , between monoidal categories and , is a monoidal adjunction if and are monoidal functors and and are monoidal natural transformations. Similarly, the adjunction is opmonoidal if both and are opmonoidal and and are opmonoidal natural transformations. There is an intermediate case, sometimes called colax-lax monoidal adjunction, which happens when is opmonoidal with structure , is monoidal with structure and the following identities hold:

 Rϕ0∘ηI=γ0,RγA,B∘ηA⊗B=ϕLA,LB∘(ηA⊗ηB).

The following theorem provides a way to transport a monoidal structure from a functor to its adjoint and obtain a colax-lax monoidal adjunction. This is a particular case of a phenomenon known as a doctrinal adjunction [10].

###### Proposition 3.

Let be an adjunction between monoidal categories and .

If is an opmonoidal functor, then has structure of monoidal functor and the adjunction is colax-lax. Moreover, if is a strong monoidal functor, then and are monoidal natural transformations.

Dually, if is a monoidal functor, then has structure of opmonoidal functor and the adjunction is colax-lax. Moreover, if is a strong monoidal functor, then and are opmonoidal natural transformations.

The following propositions state the monoidal structure of the functors involved in the Kleisli and Cayley adjunctions.

###### Proposition 4.

Considering with Day convolution and with Bénabou’s tensor, then the functor is strong monoidal, is monoidal and Cayley’s adjunction is a monoidal adjunction.

###### Proof.

The strong monoidality of Cayley’s functor was proven by Pastro and Street [17]. Applying Proposition 3, we obtain the later results. ∎

In the case of the adjunction , we obtain a “weaker” result.

###### Proposition 5.

Considering with substitution product and with Bénabou’s tensor, then the functor is monoidal, is opmonoidal and Kleisli’s adjunction is a colax-lax adjunction.

###### Proof.

The monoidality of Kleisli’s functor is well-known, see for instance [20]. Applying Proposition 3, we obtain that is monoidal. ∎

We refer to the monoidal structure of by . What we meant above by “weaker” is that we do not obtain that is strong monoidal. As we will see later, this prevents some symmetry with the Cayley adjunction. Instead of trying to obtain this condition by a careful analysis involving finiteness and imposing extra conditions [3], we rather just work with monoidality of , and put some extra effort in the next section when we show that monads are promiscuous.

The diagram of adjunctions in the previous section can now be unfolded. The functors in the upper part are opmonoidal and the functors in the lower part are monoidal.

We now give a categorical characterisation of monoids which are also algebras (coalgebras) for an idempotent monad (comonad). This definition provides a basis for presenting the right hand side of Equations 2 and 1.

###### Definition 6.

• is a monoid in ,

• is a -algebra ( is a -coalgebra).

###### Remark 5.

Notice that there is no explicit coherence condition between the monoid structure and the -algebra structure. However, the idempotency of the monad provides coherence between the two structures. For example, if is a strong monad, then a -monoid in our sense is automatically a -monoid in the sense of Fiore and Saville [6].

We can form a category of -monoids by considering morphisms between -monoids which are morphisms as monoids and morphisms as -algebras between the underlying objects. However, as the monad (comonad) is idempotent, the requirement of being a -algebra morphism becomes trivial. In fact, the -algebra structure of a -monoid is like a property: an object can have at most one -algebra structure, and in case it does, it is (). Despite that, we define a category of -monoids, as it will be useful to have a concrete name for it.

###### Definition 7.

Given an idempotent monad (comonad) on , the category of -monoids, , consists of

• Objects: -monoids.

• Morphisms: -monoid homomorphisms, i.e. morphisms in that are both monoid morphisms and -algebra (coalgebra) morphisms at the same time.

From the comment above, it is clear that is equivalent to the full subcategory of such that the underlying object of the monoid has a -algebra structure.

We are now ready to revisit the results of Lindley et al., and obtain their categorical analogues. We do so by postulating the equalities in Equations 2 and 1 as equivalences between categories.

### 4.1 Idioms are Oblivious

As already described, Lindley et al. [12] characterise idioms as the arrows in which the isomorphism

holds. The right to left morphism is available in any arrow as

B@¿l¡@E@¿l¡@[B]force::(1(ab))(ab)[E]
[B]force=λf. arr (λx. ((),x))first farr (λ(f,a). f a)[E]

From the arrow laws, it can be checked that , as defined by Lindley et al., is exactly the morphism given by the counit

 ε!(P,strP):P∗!(X,Y)=P(1,X→Y)⟶P(X,Y)

of the comonad . Therefore, the isomorphism described in Equation 1 can be expressed as a coalgebra for the idempotent comonad , i.e. an inverse for . The other part of the equation, the arrow, might be seen as a monoid in as we described in Section 2, thus obtaining that the equivalent presentation of the equation:

To show this equivalence, we must be able to move monoids from one category to another. Doing this through a monoidal functor is covered by the following classical theorem (see for instance [2]):

###### Theorem 4.

A monoidal functor can be lifted to a functor

 F∙:Mon(C)⟶Mon(D)(M,m,e)↦(FM,Fm∘ϕ,Fe∘ϕ0)

A categorical explanation of the equation is given by the following theorem, for which we give a direct proof using the theorem above.

###### Theorem 5.

Let be an adjunction in which is an isomorphism, and is strong monoidal. Then, is equivalent to .

###### Proof.

We give a direct proof of the equivalence. Using Proposition 3, we obtain a monoidal structure on , and moreover, that the adjunction is monoidal. As and are monoidal functors, they lift monoids, and give the following functors which form the equivalence.

 L∙:Mon(C)⟶Mon(LR)(M,m,e)↦(LM,Lm∘ϕ,Le∘ϕ0,Lη)
 R∙:Mon(LR)⟶Mon(C)(M,m,e,α)↦(RM,Rm∘ψ,Re∘ψ0)

In addition, we need to provide natural isomorphisms and . For we simply propose , while for we use the -coalgebra.

 γ(M,m,e):(M,m,e)⟶R∙L∙(M,m,e)γ(M,m,e)=ηβ(M,m,e,α):(M,m,e,α)⟶L∙R∙(M,m,e,α)β(M,m,e,α)=α

That is well-defined comes from , being a monoidal natural transformation and being a coalgebra for . ∎

When we apply this theorem to the case , , and , we obtain the semantic account of Equation 1:

 Mon([F,S]) and Mon(□) are equivalent categories.

We close the discussion on idioms by making the following observation. The monoidal structure given by the Day convolution on might be recovered from the one in . As the comonad is monoidal (being the composition of two monoidal functors), we could lift the monoidal structure from to the category of -coalgebras [16], which, as we noted before, is equivalent to the category of finitary functors.

In the case of monads, Lindley et al. [12] characterise them as the arrows in which the isomorphism

holds. Instead of postulating an inverse to a morphism from left to right, they follow Hughes [8] and ask for a mapping

B@¿l¡@E@¿l¡@[B]app::(ab,a)b[E]

which has to satisfy a set of three laws

 first(arr(λx. arr(λy. (x,y))))⋙app =arrid first(arr(g⋙))⋙app =secondg⋙app first(arr(⋙h))⋙app =app⋙h

These are the laws originally proposed by Hughes. Notice that such a mapping might not be expressed in our framework. Naively, it would be an element of , which is not well-defined as is not necessarily a finite set.

It can be shown, using the arrow laws, that giving a mapping which satisfies the three axioms above is equivalent to giving an inverse to the mapping

B@¿l¡@E@¿l¡@[B]eval::(ab)(a(1b))[E]
[B]eval=λc. λa. arr (λ(). a)c[E]

This map is already present in the translation of Lindley et al. in the proof of the equivalence, and corresponds to the morphism given by the unit

 η∗(P,strP):P(X,Y)⟶P∗∗(X,Y)=X→P(1,Y)

of the monad . Therefore, the isomorphism described in Equation 2 can be expressed as a algebra for the idempotent monad , i.e. an inverse for . The arrow part of the equation might be seen as a monoid in , thus obtaining that the equivalent presentation:

To prove the equivalence induced by Equation 2, we might want to use a kind-of-dual theorem to Theorem 5. However, notice that this time the left adjoint functor is not strong monoidal, but just opmonoidal, which means that we cannot easily map monoids to monoids. We need to ask for additional conditions to ensure that the left adjoint lifts monoids. This case is covered by the following lemma, which is due to Porst and Street [19].

###### Lemma 1.

Let be an opmonoidal functor and a monoid in . If

• ,

• ,

are invertible, then is a monoid in .

Using this lemma, we can prove the following theorem, which underlies the basic structure of Equation 2.

###### Theorem 6.

Let be an adjunction in which is an isomorphism, is a monoidal functor and the morphisms

 Lγ0:LI→LRJ,L(γ∘(η⊗id)):L(C⊗RD)→LR(LC⊕D)

are invertible. Then, is equivalent to .

###### Proof.

Again, we give a concrete description of the equivalence. As is monoidal, it preserves monoids, so we use Theorem 4 to lift it to monoids.

 R∙:Mon(D)⟶Mon(RL)(M,m,e)↦(RM,Rm∘γ,Re∘γ0,Rε)

The inverse function this time is a bit more complex, as is not monoidal, and therefore does not automatically preserve monoids. We use Lemma 1 to transport monoids. For a -monoid , we can construct the required inverses as

• ,

• ,

• .

We can apply Lemma 1, and obtain a functor :

Notice that each depends on an . To prove the equivalence, we need to provide natural isomorphisms and . We propose the following.

 β(M,m,e):L∙R∙(M,m,e)⟶(M,m,e)β(M,m,e)=εγ(M,m,e,α):R∙L∙(M,m,e,α)⟶(M,m,e,α)γ(M,m,e,α)=α

These are invertible, as from assumptions is invertible and has as its inverse. ∎

The following proposition provides the missing hypotheses to use the theorem above in the case we are interested.

###### Proposition 6.

The morphisms

 ξ0∗:Hom∗→(i∗)∗,(ξ∘(η∗⊗id))∗:(P⊗F∗)∗→((P∗⊕F)∗)∗

are invertible.

###### Proof.

That these morphisms are invertible can be better seen by unfolding the functor definitions on a finite set :

 ξ0∗Z:Hom(1,Z)→(1→Z)
 (ξ∘(η∗⊗id))∗Z:∫WP(1,W)×(iW→FZ)→(1→∫WP(1,W)×(iW→FZ))

As the morphisms are only using the component , they are invertible (see remark on Subsection 2.3). ∎

Finally, we obtain the categorical counterpart of Equation 2 by applying this theorem to , , , :

 Mon([F,S]) and Mon(◊) are equivalent categories.

Note that in this case we cannot make a similar observation to the one at the end of the previous subsection. The monad is not monoidal, and therefore, we cannot (easily) lift the monoidal structure from profunctors to functors. This is, partly, the symmetry that gets broken from not being strong monoidal.

## 5 Conclusions and Further Work

The relationship between different interfaces for computational effects has been studied from different perspectives. The purely syntactic approach has been covered by Lindley et al. [12]. A more programmatic account is covered by Haskell’s libraries, where the different interfaces are connected by deriving type-class instances. On the other hand, the semantic point of view for the connection was not very developed. Generally, the semantic interpretation for notions of computation focusses only on one of the interfaces, disregarding the connections between them. In this paper we have taken a first step towards the connection from the perspective of notions of computation as monoids [20].

As already remarked in the introduction, a direction of future work is to replace the category by a general category with an injection

, subject to conditions to be determined, and probably similar to those used in

relative monads [3]. A related problem is to understand these constructions in terms of Freyd categories and their variations [11, 4], as they give a semantics for arrows that do not suffer from size issues.

###### Acknowledgments.

The author is thankful to Soichiro Fujii, Pierre-Louis Curien, Marcelo Fiore and Ignacio López Franco for discussions on related topics, as well as to Hans-E. Porst and Ross Street for quick clarification on their results and pointing to related bibliography. The author is also grateful to the anonymous reviewers for their comments and suggestions.