<<

Arrows are Strong Monads

Kazuyuki Asada Research Institute for Mathematical Sciences, Kyoto University, Kyoto 606-8502, Japan [email protected]

Abstract In this way we have got a clean understanding of the categor- Hughes’ arrows were shown, by Jacobs et al., to be roughly mon- ical nature of arrows—except for the first operator. It is our ads in the Prof of profunctors (distributors, modules). main result that identifies first with a strength for a in However in their work as well as others’, the categorical nature of Prof. Therefore: arrows are strong monads in Prof. The notion the first operator was not pursued and its formulation remained of strength for a monad is employed in Moggi’s seminal work [24] rather ad hoc. In this paper, we identify first with strength for in order to accommodate “context information” within computa- a monad, therefore: arrows are strong monads in Prof. Strong tional effects—as the first operator does for arrows. Our main monads have been widely used in the semantics of functional pro- result (Theorem 14) makes this intuitive analogy a mathematically gramming after Moggi’s seminal work, therefore our observation rigorous one. establishes categorical canonicity of the notion of arrow. Use of profunctors in theoretical is not new: In categorical semantics of programming languages, profunctors— Categories and Subject Descriptors F.3.2 [Logics and Meanings often called modules (or discrete indexed categories)—are some- of Programs]: Semantics of Programming Languages—Denotational times used instead of usual categories [21, 23]. In [7, 16, 25], semantics profunctors are used as models in a domain theory for concur- rency. Also potential use of profunctors can be seen in recent work: General Terms Languages, Theory e.g. [8, 12]. Profunctor can be viewed also as “generalized relation”: a pro- Keywords arrow, strong monad, Freyd , computational is to a functor what a relation is to a . Therefore our effect, profunctor result is illustrated as: strong monad functor function 1. Introduction = = arrow profunctor relation . The notion of arrow was introduced by Hughes [17, 18] for func- tional programming languages such as Haskell. Its benefits are We define the notions of arrow and of strong monad in Prof claimed to be as follows. First, it provides more natural syntax for not only over cartesian categories but over any monoidal categories. Point-free programming; second, it allows programmers to orga- After identifying arrows as strong monads in Prof, we define the nize a bigger variety of computational effects than the notion of notion of internal strong monad in a general setting, i.e., not only in monad does. Prof. From this, we obtain some variants of the notion of arrow. This paper is about categorical semantics of arrows. There have been roughly two approaches towards that goal. The first one employs premonoidal categories with certain additional struc- 1.1 Relation to Other Work ture (called Freyd categories) [3, 22, 26]. The other is the approach ist Operator based on profunctors (also called distributors or modules) [4, 6], which we follow. As we already mentioned, this work follows the profunctor ap- In the papers [15, 19], Jacobs et al. characterized an arrow as a proach that originated in [15, 19]. In these works, they introduced monoid in a monoidal category [C op×C, Set] that is additionally what they called “internal strength”, i.e., ist operator; then they equipped with the so-called first operator. The monoidal prod- showed the equivalence between ist and first. The formulation ucts in the monoidal category [C op×C, Set] are given by certain of ist is pretty similar to that of first, but has certain technical coends; they are in fact the same as composition of profunctors. advantage, which they exploited. Then one readily sees that an arrow is a monad—in an internal It should be noted that their ist operator’s definition is quite sense—in the bicategory Prof of profunctors, equipped with a different from the genuine internal strength, i.e., the notion of first operator. strength defined for a monad in an internal way in a bicategory. The latter is what we call (internal) strength throughout the present paper. The notion of strength is a monoidal notion: it is defined for any monoidal object as in Section 6, and not only for a cartesian object. Permission to make digital or hard copies of all or part of this work for personal or On the other hand, the definition of ist operator and the proof of classroom use is granted without fee provided that copies are not made or distributed the equivalence between ist operator and strength (Theorem 16) for profit or commercial advantage and that copies bear this notice and the full citation on the first page. To copy otherwise, to republish, to post on servers or to redistribute need the structure of cartesian products. Therefore, ist operator to lists, requires prior specific permission and/or a fee. is not what should be called strength. However we can prove ist MSFP 2010 September 25, 2010, Baltimore, Maryland, USA. operator to be equivalent to strength; the name for ist was with Copyright ⃝c 2005 ACM [to be supplied]. . . $10.00 fortunate wisdom. Enriched Freyd Category and Self-enrichment In Section 5, we go straight to the main result that arrows In [3], Atkey investigated many variants of the notion of arrow. are strong monads in Prof. Also we give a direct proof of the Among them, he gave a categorical definition of arrow and also equivalence between ist operator and strength for a monad in defined the notion of enriched Freyd category, and he showed that Prof. In Section 6, we commence a more general development they are equivalent. in which strong monads in a Gray-monoid are considered. As a Atkey’s definition of arrow and that given in [15, 19] are differ- benefit of this generalization, we give some variants of the notion of ent: the former is (self-)enriched; the latter is not. This gap between arrow: especially in Section 6.3, we give a “self-enriched” version enriched and non-enriched notions was not present for monads (in of strong monad in Prof, which corresponds to Atkey’s definition Cat). This is because in a cartesian closed category—a common of arrow. setting for —strong monads are the same thing as enriched monads. 2. Background: the Notion of Arrow In the present paper, we first give the theorem that arrows The following review to the notion of arrow is brief. See e.g. [19] are strong monads in Prof in the non-enriched setting (in The- for more illustration and examples. orem 14), in order to concentrate on other aspects than such The notion of arrow [17, 18] was introduced as an extension self-enrichment problem. Then, in Section 6, we define a “self- of that of monad [5, 24, 29], and is defined in Haskell as a type enriched” version of strong monad in Prof in Definition 21, and constructor class: show that it is equivalent to Atkey’s definition of arrow in Theo- rem 23. One technical advantage of our characterization for arrow class Arrow A where is that we can define it over any symmetric monoidal category; arr :: (s → t) → A s t ( ) while for Atkey’s definition, we use structures of cartesian cate- >>> :: A s t → A t u → A s u gories (see Definition 22). first :: A s t → A (s, u)(t, u) Arrows as Relative Monads where (s, t) is the product type of types s and t. In [1], Altenkirch et al. gave a generalized notion of monad, i.e., the An instance of Arrow must satisfy the following arrow laws: ( ) ( ) notion of relative monad. A relative monad is defined over a (base) a >>>b >>>c = a >>> b >>>c (assoc) functor, while a monad is defined over a (base) category. They showed that for a category C, relative monads over the Yoneda arr (g ◦ f) = arr f >>> arr g (comp) b embedding y : C −→ C bijectively correspond to (arr,>>>)- arr id >>>a = a = a >>> arr id (id) fragments of arrows over C (in Definition 9), and hence to monads a >>> (id × f) = (id × f) >>> a over C in Prof (by Theorem 10). first arr arr first They gave also a Kleisli construction and an Eilenberg-Moore (f-din) construction for a relative monad, and showed that the Kleisli con- first a >>> arr π1 = arr π1 >>>a (f-π) struction gives the initial object and the Eilenberg-Moore construc- first a >>> arr α = arr α >>> first (first a) tion gives the terminal object in some suitable category. On the (f-α) other hand, also for a monad in Prof, we have the notions of first (arr f) = arr (f × id) (f-η) Kleisli object and Eilenberg-Moore object in Prof, as in the pa- ( ) per [27] by Street. first a >>>b = first a >>> first b (f-µ) For a relative monad R over the Yoneda embedding y of a → → category C and the corresponding monad A in Prof, the Kleisli where π1 :: (s, t) s, α :: (s, (t, u)) ((s, t) , u). category for R is isomorphic to the Kleisli object for A. They From first, we can define its dual: are isomorphic to the Kleisli category of the corresponding Freyd second :: A s t → A (u, s)(u, t) category (without premonoidal structures). a = γ >>> a >>> γ One different point between the relative monad approach and second arr first arr our approach in Prof is that the Eilenberg-Moore category for R where γ :: (s, t) → (t, s). is not necessarily equivalent to the Eilenberg-Moore object for A, Arrows subsume monads: given a monad T , we obtain its Kleisli which is the same as the Kleisli object for A (because of the duality arrow s → T t. Similarly, a comonad S induces its coKleisli arrow ∼ op Prof = Prof ). (However the “right adjoint” pseudo functor Ss → t. And we can further fit these together: with a distributive (-)b : Prof −→ CAT maps the Eilenberg-Moore object for A to law between a monad and a comonad, we can construct the biKleisli the Eilenberg-Moore category for R.) arrow Ss → T t. Uustalu, the third author of [1], extended the correspondence between (arr,>>>)-fragments of arrows and relative monads to 3. Preliminaries that between arrows (with first operators) and strong relative mon- In this section we introduce the notion of profunctor. Before that, ads [28]. yet, we first recall some necessary notions related to profunctors. Terminology 3.1 End, Coend and Yoneda Lemmas In the paper we use the term arrow exclusively for Hughes’ notion, Here we recall the notions of dinatural transformation, end and co- and not for arrows between objects in categories. For the latter, we end; the two forms of , i.e., end form and coend reserve the term . form; and Reversing Lemma. For further details, see [20] (espe- cially, Sec. 3.10). Outline Like homset C (−, −): C op ×C → Set or exponenti- In Section 2, we briefly recall the notion of arrow. In Section 3, ation bifunctors on SMCCs, we sometimes come across bifunctors we review the notions of dinatural transformation, end, coend, and with mixed variance. Dinatural transformations are between such profunctor. In Section 4, we recall the results in [19] that a fragment contra-co-variant bifunctors F,G : C op × C → D, while natural of arrow is a monad in Prof. transformations are between functors F,G : C → D. Definition 1 (Dinatural transformation) For categories C, D, and Lemma 3 For a small category C and functors F,G : C op × C → functors F,G : C op × C → D, a dinatural transformation α from Set, we have the bifunctor [F (+, −) ,G (−, +)] : C op × C → F to G is an indexed family of Set, where + and − indicate respectively variant and covariant arguments, and [−, +] is the exponentiation of Set. α : F (C,C) → G (C,C)(C ∈ |C|) C Then, denoting the set of all dinatural transformations from F which is dinatural in C, i.e., for any morphism f : C → C′ the to G by Dinat (F,G), we have a canonical isomorphism ∫ following diagrams commutes: [ ] ∼ Dinat (F,G) = F (C,C) ,G (C,C) . α F (C,C) C / G (C,C) C∈C F (hf,Chhh) 3 VGV(VC,fV+ ) ′ ′ F (C ,C) VV h4 G (C,C ) Proof. Because of the following bijective correspondences: V+ hh ∫ [ ( ) ] ′ ′ ′ / ′ ′ ′ F (C ,f)F (C ,C ) G (C ,C )G(f,C ) 1 → F C,C ,G (C,C) αC′ C∈C ( [ ]) (by (1)) 1 → F (C,C) ,G (C,C) C Two successive dinatural transformations do not necessarily C dinatural in compose, in which sense this notion is not that of “morphism” → between such bifunctors. Nevertheless dinatural transformations (F (C,C) G (C,C))C dinatural in C are useful, as we will see many times in the paper. Note that the notion of dinatural transformation subsume that of As noted above, natural transformations are subsumed by dinat- : for given functors F,G : C → D, natural ural transformations. Hence, for functors F,G : C → Set, we transformations between F,G bijectively correspond to dinatural have also a canonical isomorphism transformations between F ◦ π′,G ◦ π′ : C op × C → D. Also ∫ ∼ we will see many examples of dinatural transformations where the Nat (F,G) = [F C, GC] domain functors (F above) or the codomain functors (G above) are C∈C constant functors, as in the next definitions of end and coend. where the left hand side is the set of natural transformations from End (resp. coend) is a kind of limit (resp. colimit) where di- F to G. These isomorphisms are useful throughout the paper for natural transformations are used instead of natural transformations. calculating (di)natural transformations, especially in the proof of These notions play a very important role for profunctor theory. Theorem 14. F : C → Set Definition 2 (End and Coend) For categories C, D, and a functor By the usual Yoneda lemma, for a functor , there FC ∼ Nat (y (C) ,F ) F : C op × C → D, is canonically the natural isomorphism = . ∫ Replacing the right hand side with the end isomorphic to it, we • D an end of F is an object C∈C F (C,C) in with projection have the Yoneda lemma, end-form: morphisms (∫ ) Lemma 4 (The Yoneda lemma, end-form) For a small category ( ′ ′)( ′ ) C and a functor F : C → Set, we have a canonical natural ′ → ∈ |C| πC : F (C,C) F C ,C C isomorphism C∈C ∫ ∫ [ ( ) ] ∼ C ′ ′ which form a dinatural transformation from the C∈C F (C,C)- FC = C,C ,FC . constant functor to the functor F . Then these are required to be C′∈C universal among such data: i.e., for any object D in D and ′ ′ Above, we use the exponentiation [−, −] in Set. This is called ′ → any dinatural transformation (αC : D∫ F (C ,C ))C′ ,there → also cotensor in enriched [20], and there is its dual is a unique morphism f : D C∈C F (C,C) such that ′ notion called tensor, which is just cartesian product in the case of ′ ◦ ′ πC f = αC for all C . Set. With this we can obtain the dual version of the above Yoneda ∫ ∈C • Dually, a coend of F is an object C F (C,C) in D with Lemma: injection morphisms ∫ Lemma 5 (The Yoneda lemma, coend-form) For a small category C∈C ( ′ ′) ( ′ ) C and a functor F : C → Set, we have a canonical natural ′ → ∈ |C| ιC : F C ,C F (C,C) C isomorphism ∫ ′ op op op op op C ∈C ( ) ( ) which forms an end of F :(C ) × C → D .  ′ ′ ∼ F C × C C ,C = FC . The universality of an end and a coend can be written respec- tively as the following bijective correspondences: Note that we can of course apply the above two lemmas also to ∫ a contravariant functor F : C op → Set. → f : D C∈C F (C,C) We need also the next lemma in the proof of the main theorem. (1) As homset functors reverse colimits into limits in the negative ( f ) D →C F (C,C) C position, they reverse also coends into ends. C dinatural in ∫ C C∈C Lemma 6 (Reversing Lemma) For a category and a functor f : F (C,C) → D F : C op × C → Set, we have a canonical natural isomorphism (2) [∫ ∈C ] ∫ ( f ) C [ ] F (C,C) →C D C ∼ C dinatural in F (C,C) , − = F (C,C) , − . C∈C The complete and cocomplete category Set has all ends and coends. 3.2 Profunctor A typical and important example of an end is a set of dinatural transformations: The notion of profunctor (also called distributor or module) forms the very basis of our analysis of arrows. The notion dates back for quite a while, and its relevance to theoretical computer science has We denote by Prof the bicategory consisting of small cat- been recently recognized [8, 12]. egories as its 0-cells (objects), profunctors as its 1-cells (mor- Here we recall the notion of profunctor, the bicategory Prof, phisms), and 2-cells between profunctor as its 2-cells. the embedding of Cat into Prof, and tensor product in Prof. Next we introduce an embedding of Cat into Prof. This is As mentioned in the Introduction, a profunctor is to a functor identity on 0-cells (small categories), maps a functor F : C −→ D what a relation is to a function. This analogy is used repeatedly to the following profunctor F∗ : C −→+ D called direct image of for illustration. For further details and illustrations for profunctors, F , see [4, 6]. def op F∗ (−, +) = D (−,F +) : D × C −→ Set (6) Definition 7 (Profunctor) Let C and D be small categories. A ⇒ ′ C −→ D profunctor from C to D is a functor D op × C −→ Set. We denote and maps a natural transformation σ : F = F : to the D ⇒ ′ C −→ D such a profunctor by F : C −→+ D, i.e., natural transformation (id, σ): F∗ = F ∗ : + . This embedding forms a pseudofunctor [6] from the 2-category F : C −→+ D, a profunctor Cat to the bicategory Prof, i.e. preserve composition and identi- (3) ties for 1-cells up to iso-2-cells. This embedding corresponds—via F : D op × C −→ Set, a functor the foregoing analogy—to the embedding of the category Set into the category Rel of sets and relations, which maps a function to its For successive profunctors F : C −→+ D and G : D −→+ E, graph relation. their composition G ◦ F : C −→+ E is defined—under the corre- As cartesian products in Set lift to tensor products in Rel, spondence (3)—as the following functor: cartesian products in Cat lift to tensor products in Prof. For profunctors F : C −→+ C′ and G : D −→+ D′, we define F × G : G◦F C × D −→ C′ × D′ E op × C / + by the following: Set ( ) ( ) ( ) ∫ (4) ′ ′ def ′ ′ / D∈D F × G F × G (E,C) G (E,D) × F (D,C) ( ) C ,D ,C,D = C ,C D ,D (7) It is obvious that the operator × acts also on natural transformations Its action on morphisms is the obvious one. between profunctors. For a category C, we define the identity profunctor + op IdC : C −→+ C by C (−, −): C × C −→ Set . (5) 4. Monad in Prof Given two parallel profunctors F, F ′ : C −→+ D, a 2-cell In this short section, we review the result by Jacobs et al. [15, 19] between profunctors σ : F =⇒ F ′ is just a natural transformation that monads in Prof are equivalent to the (arr,>>>)-fragment of σ : F =⇒ F ′ where F and F ′ are regarded as the functors from arrows. This forms also a preliminary step toward our main result, D op × C to Set.  Theorem 14.

Now, let us illustrate the definition above using the analogy with 4.1 Monads in Prof as Bases of Arrows relations. A relation R between sets S and T is a subset of the Many notions in category theory consist of functors and natural product set S ×T , in other words, a function from S ×T to the two transformations, subject to some commutative diagrams. For ex- points set {0, 1}. Thus, a profunctor—F : D op ×C −→ Set—is a ample, an adjunction is a tuple (F, G, η, ϵ) of two functors and two Set-many valued relation, while a relation is two valued. Next let natural transformations, subject to the two triangular laws [6, The- us recall how the relational composition S ◦ R is defined: orem 3.1.5]. Once one takes a 2-categorical view on this—functors def and natural transformations are 1-cells and 2-cells in Cat—it is (S ◦ R)(c, e) ⇐⇒ ∃d. R (c, d) ∧ S (d, e) straightforward to define an adjunction in an arbitrary 2-category, or in a bicategory, in an “internal” way [27]. The notion of (inter- Then there are obvious similarity between∫ composition for pro- D nal) monad is also one of such. functors (4) and that for relations: coend corresponds to ∃d., and × to ∧. Also, 2-cells σ between profunctors F and F ′, i.e., nat- Definition 8 (Monad) Let P be a bicategory, and C be a 0-cell in F −→ F ′ P C P A ural transformations (σD,C : (D,C) (D,C))D,C cor- .A monad over in is a triple ( , η, µ) of an endo-1-cell 2 respond to the inclusion order between relations: A : C −→ C in P and 2-cells η : IdC =⇒ A and µ : A =⇒ A ( ) in P satisfying the usual commutative diagrams of associativity ′ def ′ R ≤ R ⇐⇒ ∀c.d. R (c, d) ⇒ R (c, d) . and unitality.  This analogy between profunctor and relation will be helpful to It should be noted that this internal definition coincides with the understand many notions for profunctor. usual one if P = Cat. The notion of 2-category is now used in many different contexts; C in a 2-category, there is a notion of 2-cell, which is “morphism Definition 9 ((arr,>>>)-Fragment of Arrow) For a category , C between morphisms.” A typical example is the 2-category Cat of an (arr,>>>)-fragment of arrow over consists of a mapping |C| × |C| −→ | | categories, functors, and natural transformations. Ar : Set and two families of mappings:

One might imagine that the notions of category, profunctor arrAB : C (A, B) −→ Ar (A, B) between categories, and 2-cell between profunctors form a 2- × −→ category. However, the composition for profunctors is not strictly >>>ABC : Ar (A, B) Ar (B,C) Ar (A, C) associative, because of the coends and products in the definition. These must satisfy Axioms (assoc), (comp), and (id) in Section 2, Likewise, identity profunctors are not strictly unital. Nevertheless, where we use variables f, g for morphisms in C, and use a, b, c for they hold up to canonical iso-2-cells; e.g., the iso-2-cells for the  elements in (Ar (A, B))A,B. unitality can be gotten by the Yoneda lemma, coend-form. Such notion which is similar to that of 2-category, but whose associativ- The map Ar above is a mapping to |Set| rather than |C|. This is ity and unitality of the composition of 1-cells are required just up unnatural if we use the above definition of arrows to model arrows to iso-2-cells, is called bicategory [6]. as type constructors in Section 2. This involves a subtle size issue, and we solve it in Section 6.3, till then we shall separate such a size 5.2 first Operator for Monoidal Categories issue. Here and in the next section, we focus on the correspondence To give the main theorem for any monoidal categories, here we between arrows and strong monads in Prof. generalize the definition of first operators from that for cartesian Theorem 10 [15, 19] For a small category C, the notion of monad categories to that for monoidal categories. (This modification is over C in Prof is equivalent to that of (arr,>>>)-fragment of used in the proof of the main result. It is not an indirect way but arrow over C.  a natural way even for cartesian categories; a cartesian category seen in Prof is not a “cartesian object” but a monoidal object (see Proof. (Sketch) Given a monad (A, η, µ) in Prof over a small Section 6) in Prof.) op category C, A is a functor from C × C to Set; this corresponds In order to give a categorical definition of first operators for to the mapping Ar of a fragment of arrow, where the functoriality monads in Prof over monoidal categories, we need to modify of A is recovered with arr and >>>. The natural transformations η Axiom (f-π) (described in Section 2), since a monoidal category C −→ A C − − has components ηA,B : (A, B) (A, B) since ( , ) is does not necessarily have projections π. For this, we use ρ : an identity 1-cell in Prof. This corresponds to arr. Finally, µ is, A⊗I −→ A instead of π: by (4), a natural transformation with components ∫ ( B ) Definition 12 [first Operators for Monoidal Categories] For a µA,C : A (A, B) × A (B,C) −→ A (A, C) , monoidal category (C, ⊗, I, α, λ, ρ) and a monad (A, η, µ) over C in Prof, a first operator is a family of morphisms firstA,B,C : which corresponds to >>> by the universality (2) of the coend.  A (A, B) −→ A (A⊗C,B⊗C) natural in A, B ∈ C, dinatural in C ∈ C, and satisfying Axioms (f-α), (f-η), and (f-µ) in Section 2 In the remaining sections, we use arr, >>> and η, µ interchange- and (f-ρ): ably, especially in Definition 12. first a >>> arr ρ = arr ρ >>>a (f-ρ) 5. Arrows as Strong Monads in Prof In this section, we present our main result (Theorem 14) that arrows Note that the naturality in A and B above are redundant: are strong monads in Prof. We give this theorem not only for they are derived from Axioms (f-η) and (f-µ). Also note that Ax- cartesian categories, but for any monoidal categories. iom (f-din) in Section 2 is equivalent to the dinaturality above. In order to show the main result, we first need to define the The propriety of the above definition is justified by the next notion of strength in Prof. Then we generalize the definition proposition: of first operator, from that for cartesian categories to that for monoidal categories. Finally we show that these notions of strength Proposition 13 In the situation of Definition 12, if the monoidal and first are equivalent. category C is a cartesian category, then Axiom (f-ρ) is equivalent to Axiom (f-π).  5.1 Strength in Prof First let us review strength in Cat. A strength for a monad over a C ⊗ Proof. The direction from (f-π) to (f-ρ) is trivial. For the converse, monoidal category ( , , I) is a natural transformation strA,B : Axiom (f-π) is gotten from (f-ρ) as the following: TA⊗B −→ T (A⊗B) satisfying certain axioms. This 2-cell in Cat can be also described as the following: A × × (A C,B !C ) / A (A ×= C,B × C) A (A ×: C,B × 1) T ×IdC / { tt C × C C × C {{ tt {{ (dinaturality) t first { A(A×! ,B×1) tt {{ C t ⊗ str ⊗ { tt ⇐ { t first /   A A × × A(A×C,ρ) / (A, BCC) (At 1,B 1) C C CC tt T CC tt A C (f-ρ) ttA × (functoriality) (ρ,B) CC tt (A 1,ρ) In a similar way, we define the notion of strength in Prof. C! ty t  Definition 11 (Strength) Let (C, ⊗, I, α, λ, ρ) be a monoidal cat- A (A × 1,B) / A (A × C,B) A × egory, and (A, η, µ) be a monad over C in Prof. (A !C ,B) A strength for the monad A in Prof is a 2-cell str in Prof In the above, !C : C −→ 1 is the unique map from C to the in the following diagram such that it satisfies the usual four axioms ◦ × × −→ × −→ with α, ρ, η, µ (for these axioms, see Definition 20). terminal, hence ρ A !C : A C A 1 A is equal to the projection π1 : A × C −→ A. The upper path of the above A×Id+ diagram is the left hand side of (f-π), and the lower path is the right C / C × C C × C hand side. 

⊗∗ _ str _⊗∗ ⇐ 5.3 Arrows as Strong Monads in Prof   C / C A Now we show the main result.

We call a monad in Prof equipped with a strength in Prof a Theorem 14 For a monoidal small category (C, ⊗, I, α, λ, ρ) and strong monad in Prof.  a monad (A, η, µ) on C in Prof, there is a bijective correspon- dence between first operators and strengths for (A, η, µ) in This is a key notion in the paper. It should be noted that since Prof. the two vertical 1-cells in the above diagram are in Prof, we use the embedding (6) of Cat into Prof, so that the functor ⊗ : C × C −→ C is replaced with its direct image ⊗∗. Proof. The following calculation of ends and coends shows the B ∈ C, dinatural in A ∈ C, and satisfying the following axioms: correspondence between strength (in LHS) and first (in RHS): ( ( ) ) ist (arr f) = arr ⟨f, id⟩ ⊗ ◦ A × + A ◦ ⊗ Nat ( ∗) IdC , ( ∗) ist a >>> arr π = a ( )1 ∼ ( by Lemma 3 ) ∫= ist a >>>b = [( ( ))( ) ( )( )] ( ) + ist a >>> ist arr π >>>b >>> arr (id×π ) ⊗∗ ◦ A×IdC C, (A, B) , A ◦ ⊗∗ C, (A, B) 1 2 A,B,C ist (ist a) = ist a >>> arr ⟨id, π2⟩ = ( by Definition 7 - (4) ) [ ′ ′ ∫ A∫,B( ( )) (( )( )) ( ) ( ) ( ) Theorem 16 For a cartesian small category C, and a monad ⊗ ′ ′ × A× + ′ ′ ∗ C, A,B IdC A,B , A,B , (A, η, µ) on C in Prof, there is a bijective correspondence be- A,B,C tween ist operators and strengths for (A, η, µ) in Prof.  ′ ] ∫C ( ) ( ( )) ′ ′ ( ) A C,C × ⊗∗ C , A, B Proof. Here we concentrate only on the correspondence between (di)natural transformations of ist operators (in RHS) and strengths = ( by the definitions of (−) (6), tensor × (7), and Id+ (5) ) (in LHS): [ ∗ C ( ) ∫ ∫ ′ ′ ( ) A ,B + ( ′ ′) ( ′ ) ( ′ ) Nat (×∗) ◦ A × Id , A ◦ (×∗) C C,A ⊗B ×A A ,A ×C B ,B , C ∼ A,B,C ] = ( by Lemma 3 and definitions, as in the proof of Theorem 14 ) ∫ ′ [ C ( ) ( ) ∫ ∫ ′ ′ ′ ′ A ,B ( ) ( ) ( ) A C,C ×C C ,A⊗B ′ ′ ′ ′ C C,A ×B ×A A ,A ×C B ,B , A,B,C ] ∼ ′ ′ ∫ ′ = ( by Lemma 5 on B ,C ) C ( ) ( ) [ ] ′ ′ ∫ ∫ ′ A ×C × A C,C C ,A B ( ′ ) ( ′ ) C C,A ⊗B ×A A ,A , A (C,A⊗B) ∼ ′ ′ A,B,C = ( by the adjointness of the cartesian product A ×B ) [ ∼ ∫ ∫ ′ ′ = ( by Lemma 6, then Currying ) A ,B ( ) ( ) ( ) ( ) ∫ [ ] C ′ ×C ′ ×A ′ ×C ′ ( ′ ) [ ( ′ ) ] C,A C,B A ,A B ,B , C C,A ⊗B , A A ,A , A (C,A⊗B) A,B,C ] ′ ∫ ′ A,B,C,A C ( ′) ( ′ ) ∼ ( by Lemma 4 on C ) A C,C ×C C ,A×B ∫= [ ( ) ( )] A ′ A ′⊗ ⊗ ∼ ′ ′ ′ A ,A , A B,A B = ( by Lemma 5 on A ,B ,C ) A,B,A′ ∫ ∼ [ ] = ( by Lemma 3 ) A ×C A × ( ) (C,A) (C,B) , (C,A B) ( ′ ) ( ′ ) A,B,C Nat ′ Dinat A A ,A , A A ⊗B,A⊗B A ,A B ∼ ( by Currying ) ∫= [ [ ]] The remaining is to prove the equivalences between the ax- C (C,B) , A(C,A) , A(C,A×B) ioms for strength and those for first: the four axioms for strength A,B,C ∼ ( by Lemma 4 on B ) with α, ρ, η, and µ correspond respectively to (f-α), (f-ρ), (f-η), ∫= and (f-µ). The proofs of these equivalences are tedious but straight- [ ] A A × forward.  (C,A) , (C,A C) A,C ∼ In this way we can characterize simply the notion of arrow = ( by Lemma 3 ) ( ) only with basic structures of the bicategory Prof. This simplicity A A × and rich structures of Prof make it easy to calculate, in Prof, DinatA,C (C,A) , (C,A C) properties and structures on arrows, as in the paper [2]. Besides, this characterization provides a better justification of the axioms of The steps are almost the same as in the proof of Theorem 14, arrows, and provides us clean understanding of the notion of arrow. except that we used adjointness of cartesian products for the second  5.4 On ist Operators isomorphism. On a cartesian category as a base of an arrow, there is an alternative to a first operator, i.e., an ist operator [15, 19]. 6. Generalizing Arrow Applying the theorem in the previous subsection to cartesian In this section, we generalize the definition of strong monad by small categories, we see that strengths are equivalent to first enlarging a class of ambient in which internal strong operators, hence also to ist operators. However, we give a direct monad is defined. So far in the paper, such an ambient bicategory is proof of correspondences between strengths in Prof and ist Cat or Prof. We see first which kind of bicategories can be used operators. The proof shows how the notion of ist operator depends for such purpose; then we define the notion of strength in there. on cartesian products. By this generalization we obtain some variants of the notion Definition 15 (ist Operator) For a cartesian category C and a of arrow. Especially in the last, we give a definition of “self- monad (A, η, µ) over C in Prof, an ist operator is a family enriched” version of arrow, which is shown to be equivalent to of morphisms istA,B : A (A, B) −→ A (A, B×A) natural in Atkey’s definition of arrow. 6.1 Gray Monoid Example 18 Let V be a cocomplete SMCC. Then, there is a notion V V Monads in Cat are defined over any category, while strong monads of -profunctor, also called -module [20]. For V-categories C and D, a V-profunctor F from C to D is a in Cat are defined only over monoidal categories. Hence when V F D op  C −→ V V F we define strong monads in bicategories, we first have to define -functor : , and for parallel -profunctors and F ′, a 2-cell between V-profunctors F and F ′ is a V-natural monoidal objects in bicategories. F F ′ Much like we need monoidal categories as ambient categories transformation from to . in which we define monoid objects, we need monoidal bicate- Then, as the monoidal bicategory Prof, we can define a monoidal bicategory V-Prof of small V-categories, V-profunctors, gories [13] as ambient bicategories in which we define monoidal V objects. (These phenomena of occurrences of similar kinds of in- and 2-cells between -profunctors. The monoidal product in V-Prof is the same as the tensor product in V-Cat, which we ner and outer structures are called “the microcosm principles”, ad-  V  vocated by Baez and Dolan [14].) denote by . In the case that = Set, Set-Prof is Prof. We can in fact use monoidal bicategories to define monoidal V objects. However, the structural isomorphisms of a monoidal This -Prof plays an important role in Section 6.3. bicategory—up to which the composition of 1-cells and also the monoidal product are associative and unital—are cumbersome and make the essence blurred. Therefore we here use the notion of 6.2 Monoidal Object and Strong Monad Gray monoid, which is, roughly, “strictified monoidal bicate- First we recall the notion of monoidal object in a Gray monoid [11]. gory”. P  I Definition 17 (Gray monoid) A Gray monoid P is a 2-category Definition 19 (Monoidal Object) Let ( , , ) be a Gray monoid. P  I with the following structures: A monoidal object (or pseudomonoid) in ( , , ) is a 0-cell C in P together with 1-cells ⊗ : C  C −→ C and I: I −→ C • a 0-cell I, in P and invertible 2-cells α, λ, and ρ below such that they satisfy • for each 0-cell C in P, two 2-functors LC, RC : P −→ P coherence axioms quite similar to those for monoidal categories. satisfying the following conditions (See [11], for further detail.)

def LC (D) = RD (C) (and define C  D = LC (D)), ⊗C / IC / o CI C3 C2 C @@ C2 C LI = RI = IdP, @@@@ ~~~~ @@ λ ρ ~~ @@ ⇐ ⇐ ~~ LCD = LCLD, RCD = RDRC, RDLC = LCRD, C⊗ α ⊗ @@ ⊗ ~~ ⇐ @@ ~~ @@@@ ~~~~ for all 0-cells C, D, and    ~~ ′ ′ C2 / C C • for each 1-cells F : C −→ C , G : D −→ D , an invertible ⊗ 2-cell L (G) C / ′ C  D C  D Monoidal objects in Cat are monoidal categories. Monoidal objects in Prof are called promonoidal categories [9, R F cF,G R F 10]. In Section 5.1, we considered only the promonoidal categories D( ) ⇒ D′ ( ) induced from monoidal categories via the direct image embedding.   ′ / ′ ′ (The direct image embedding is monoidal pseudofunctor, hence C  D C  D maps monoidal objects in Cat to those in Prof.) LC′ (G) Now we define strong monads in Gray-monoids: satisfying certain coherence axioms such as cIdC,IdD = idCD, see [11] for details.  Definition 20 (Strong Monad in Gray-Monoid) Let (P, , I) be a Gray-monoid, (C, ⊗, I, α, λ, ρ) be a monoidal object in In what follows, we denote LC by C(−) and RC by (−)C. P  I A C P ′ ′ ( , , ), and ( , η, µ) be a monad over in . Note that for 1-cells F : C −→ C and G : D −→ D , A P  I ′ ′ A strength for the monad in ( , , ) is a 2-cell str CG; F D and F D; C G are not necessarily the same, so we in P in the following diagram such that it satisfies the ax- cannot denote them simply by F G. However they are isomorphic ioms (s-α), (s-ρ), (s-η), and (s-µ) below. with the iso-2-cell cF,G , and we can always interchange them. Gray In the definition of -monoid, all structural isomorphisms AC / of monoidal bicategory are replaced with identities, except for c. C2 C2 Even associativity and unitality—both of the composition of 1- ⊗ str ⊗ cells and of monoidal product—are strict. By this simplicity, we ⇐ can keep definitions of monoidal object and strength accessible.   C / C All Gray monoids form monoidal bicategories, and conversely A by the strictification theorem [13], all monoidal bicategories are monoidally equivalent to some Gray monoids. (It is not true that all monoidal bicategories are monoidally equivalent to some AC2 C⊗ AC2 C⊗ monoidal 2-categories [13].) Hence we identify monoidal bicate- C3 / C3 / C2 C3 / C3 / C2 Gray FF x; gory with monoid. F x ⊗C FF c xx F ⇐ x The 2-category Cat forms a monoidal 2-category with carte- C⊗ # xAC strC  –1 ⇐ α sian products. The bicategory Prof forms a monoidal bicategory ⊗C 2 ⊗ ⊗C 2 ⇐ ⊗ C = x; C FF (s-α) with the tensor product ×, as the category Rel forms a monoidal ACx F⊗ α–1 ⊗ str xx F

⇐ F ⇐ x str category with the tensor product ×.     x ⇐ F#  C2 / C / C C2 / C / C We can generalize Prof with enriched category theory: ⊗ A ⊗ A ′ ′ C AC V V V I / / CI AC to J) is a strong monad over in -Prof whose underlying - C EE C2 C2 / 2 / 2 EEE C EE C ; C endoprofunctor is V-small.  EE ρ E C w EE⇐ ⊗ str ⊗ E c–1 wIw E ⇐ = ⊗ (s-ρ) EE E ⇐ w   A E w ρ  " w ⇐ C / C We show that the above definition gives a generalization of A C C Atkey’s definition of arrow, from that over a cartesian category to that over a monoidal category. ; C2 E ηCxx EE In the definition below, we use the coKleisli category of the ⇐ x ⊗E ⊗ η x str E ⇐ x ⇐ E = C2 / C / C (s-η) comonad D × (−) for each object D in a cartesian category C. xAC " A C2 / C / C Note that if a base category is cartesian, so is its coKleisli category. ⊗ A Definition 22 [3] An arrow on a cartesian category C consists AC AC 2 / 2 / 2 AC / AC / of a mapping of objects Ar : |C| × |C| −→ |C| and three C C C C2 C2 CA 2 ⊗ transformations all natural in D, µC str  str ⇐ ⇐ ⇐ arr : C (D × A, B) −→ C (D, Ar (A, B)) ⊗ w; C HH ⊗ = ⊗ AC ⊗ (s-µ) DAB A ww HHA C × C ww HH str >>>DABC : (D, Ar (A, B)) (D, Ar (B,C)) w µ H  ⇐ 

 ⇐  w /# C / C −→ C C C A (D, Ar (A, C)) A firstDABC : C (D, Ar (A, B)) −→ C (D, Ar (A × C,B × C)) We call a monad in P equipped with a strength in (P, , I) a These transformations must satisfy the eight laws (assoc) – (f-µ) in strong monad in (P, , I).  Section 2 where the equations are interpreted as equations between C By this definition with P = Prof, we can in fact define arrows morphisms generated by the above transformations. In those equations, we use variables f, g for morphisms in C (D × A, B) not only over monoidal categories as in Section 5 but also over C any promonoidal categories; on the other hand, we have no similar and a, b, c for morphisms in (D, Ar (A, B)); and the composi- tion ◦, identity id, product × and projection π1 are all those in the theorem to Theorem 14, because first-operators are defined only  for monoidal categories. coKleisli category noted above. Theorem 23 For a cartesian category C, the notion of arrow over 6.3 Self-enrichment of Arrow C defined in Definition 22 is equivalent to that of small strong In the last place, we consider a solution for the following problem monad over C in Cb-Prof with respect to the Yoneda embedding pointed out in the paper [3]: For a CCC C, let us identify types and y : C −→ Cb.  terms in Haskell with objects and morphisms in C, respectively. An arrow A in Haskell is a type constructor, hence maps two types to Proof. Basically, this proof is almost the same as Proof 10 and 14. ◦ a type; i.e., A is not a functor C op × C −→ Set but a functor Since a small strong monad A is decomposed as y ◦ A by C op × C −→ C. definition, it is obvious that this corresponds to Ar of an arrow of In order to replace Set with C, a naive way is to consider strong Definition 22: C Prof C ◦ def monads in - in Example 18. However then is required to A (A, B) = Ar (A, B) (8) be small cocomplete and small at the same time, which implies that C must be a preorder. The use of the synthetic domain theory, which The unit η of a small strong monad A over C is a natural Cb- admits non-trivial internal small cocomplete categories, is not nat- b + transformation from the identity C-profunctor IdC to A, i.e., a ural just for this purpose; for it unnecessarily restricts models. family of morphisms The solution that we give for this is use of cocompletion and to ( ) → −→ A◦ distinguish “small” ones from “large” ones. ηA,B : yA CbyB y ( (A, B)) Now let V be an SMC, V′ be a sufficiently cocomplete SMCC, ′ Cb ∈ C → and J : V −→ V be a symmetric strong monoidal fully faith- in natural in A, B . Here the presheaf yA CbyB is iso- morphic to the presheaf C (− × A, B), by Yoneda lemma. On ful functor, whose leading example is the Yoneda embedding A◦ V −→ Vb V V′ the other hand, by the correspondence (8), y ( (A, B)) = y : . Then can be a -category with hom-objects C − def ( , Ar (A, B)). As this, η corresponds to arr. ( ′ homV (A, B) = JA V JB. The underlying category of this A correspondence between µ and >>> is readily obtained as in V′ V V -category is isomorphic to the category itself; also J can Proof 10. V′ be -functor whose underlying functor is again J. Finally, we can easily prove that str corresponds to first, V′ F C −→ D F V For a -profunctor : + , we call -small if the with the full-faithfulness of y, and as in Proof 14, where we use V′ F D op  C −→ V′ V′ -functor : is factorized along the -functor Cb-enriched version of Lemma 3, 4, 5, and 6 (see [20, Sec. 3.10]). J : V −→ V′: b F Example 24 Besides Yoneda embeddings C −→ C, we can also op / ′ D  CQQ VO use the inclusion Set ,→ Ens, the codomain of which is the QQQ QQQ category of classes. Then we have the notion of small strong monad ◦ QQ J op F QQ over Set in Ens-Prof: A : Set × Set −→ Set. QQ( V In the paper [2], such notion is used, to obtain some endofunctors over Set—rather than functors from Set to Ens—for which we Such factors of F are unique up to natural V′-isomorphism, and we can consider coalgebras.  denote the V′-functor from D op  C to V by F ◦. (Note that when ◦ J is the Yoneda embedding, which is injective, F is uniquely Acknowledgments determined.) I would like to thank Ichiro Hasuo for encouraging me to write Definition 21 For an SMC V and an embedding J : V −→ V′ the paper, helpful comments for early draft, and discussions, and as above, a small strong monad over V in V′-Prof (with respect also thank Paul-Andre´ Mellies` for teaching me profunctors, and higher dimensional category theory. Also I am grateful to Shin-ya [19] B. Jacobs, C. Heunen, and I. Hasuo. Categorical semantics for arrows. Katsumata, Bart Jacobs, Pastro Craig, and Naohiko Hoshino for Journal of Functional Programming, 19(3-4):403–438, 2009. ISSN useful comments and discussions. 0956-7968. This work is supported by the GCOE Program, JSPS; and also [20] G. M. Kelly. Basic Concepts of Enriched Category Theory. Number 64 by the PRESTO Research Promotion Program, JST (principal in- in LMS. Cambridge Univ. Press, 1982. vestigator: Ichiro Hasuo). [21] P. B. Levy. Call-By-Push-Value: A Functional/Imperative Synthesis, volume 2 of Semantics Structures in Computation. Springer, 2004. ISBN 1-4020-1730-8. References [22] P. B. Levy, A. J. Power, and H. Thielecke. Modelling environments in [1] T. Altenkirch, J. Chapman, and T. Uustalu. Monads need not be call-by-value programming languages. Inf. & Comp., 185(2):182–210, endofunctors. In C.-H. L. Ong, editor, FOSSACS, volume 6014 of 2003. ISSN 0890-5401. Lecture Notes in Computer Science, pages 297–311. Springer, 2010. [23] E. Moggi. Computational lambda-calculus and monads. In LICS, ISBN 978-3-642-12031-2. pages 14–23. IEEE Computer Society, 1989. [2] K. Asada and I. Hasuo. Categorifying computations into components [24] E. Moggi. Notions of computation and monads. Information and via arrows as profunctors. To appear in Proc. International Workshop Computation, 93(1):55–92, 1991. on Coalgebraic Methods in Computer Science (CMCS 2010)., 2010. [25] M. Nygaard and G. Winskel. Domain theory for concurrency. Theor. [3] R. Atkey. What is a categorical model of arrows? Electr. Notes Theor. Comput. Sci., 316(1):153–190, 2004. Comput. Sci, To appear. [26] J. Power and E. Robinson. Premonoidal categories and notions of [4] J. Benabou.´ Distributors at work. Lecture notes by Thomas Streicher, computation. Math. Struct. in Comp. Sci., 7(5):453–468, 1997. 2000. [27] R. Street. The formal theory of monads. Journal of Pure and Applied www.mathematik.tu-darmstadt.de/~streicher/FIBR/DiWo.pdf.gz. Algebra, 2:149–168, 1972. [5] N. Benton, J. Hughes, and E. Moggi. Monads and effects. In [28] T. Uustalu. Strong relative monads. Short contribution in International G. Barthe, P. Dybjer, L. Pinto, and J. Saraiva, editors, Advanced Lec- Workshop on Coalgebraic Methods in Computer Science (CMCS tures from Int. Summer School on Applied Semantics, APPSEM 2000 2010)., 2010. (Caminha, Portugal, 9–15 Sept. 2000), volume 2395 of Lecture Notes [29] P. Wadler. Monads for functional programming. In Lecture Notes in Computer Science, pages 42–122. Springer-Verlag, Berlin, 2002. In Computer Science, Vol. 925; Advanced Functional Programming, [6] F. Borceux. Handbook of Categorical Algebra 1: Basic Category The- First International Spring School on Advanced Functional Program- ory, volume 50 of Encyclopedia of Mathematics and Its Applications. ming Techniques-Tutorial Text, pages 24–52, London, UK, 1995. Cambridge University Press, Cambridge, 1994. Springer-Verlag. ISBN 3-540-59451-5. [7] G. Cattani, M. Fiore, and G. Winskel. A theory of recursive domains with applications to concurrency. In Proc. of LICS ’98, 0:214–225, 1998. ISSN 1043-6871. [8] P.-L. Curien. Operads, clones, and distributive laws. preprint, www.pps.jussieu.fr/~curien, 2008. [9] B. Day. On closed categories of functors. In Reports of the Midwest Category Seminar, IV, Lecture Notes in Mathematics, Vol. 137, pages 1–38. Springer, Berlin, 1970. [10] B. Day. On closed categories of functors. II. In Category Semi- nar (Proc. Sem., Sydney, 1972/1973), pages 20–54. Lecture Notes in Math., Vol. 420. Springer, Berlin, 1974. [11] B. Day and R. Street. Monoidal bicategories and Hopf algebroids. Adv. Math., 129(1):99–157, 1997. ISSN 0001-8708. [12] M. Fiore, N. Gambino, M. Hyland, and G. Winskel. The cartesian closed bicategory of generalised species of structures. Journ. of Lon- don Math. Soc., 77:203–220, 2008. [13] R. Gordon, A. J. Power, and R. Street. Coherence for tricategories. Mem. Amer. Math. Soc., 117(558):vi+81, 1995. ISSN 0065-9266. [14] I. Hasuo, B. Jacobs, and A. Sokolova. The microcosm principle and concurrency in coalgebra. In Foundations of Software Science and Computation Structures, volume 4962 of Lect. Notes Comp. Sci., pages 246–260. Springer-Verlag, 2008. [15] C. Heunen and B. Jacobs. Arrows, like monads, are monoids. Electr. Notes Theor. Comput. Sci, 158:219–236, 2006. URL http://dx.doi.org/10.1016/j.entcs.2006.04.012. [16] T. T. Hildebrandt, P. Panangaden, and G. Winskel. A relational model of non-deterministic dataflow. In D. Sangiorgi and R. de Simone, ed- itors, CONCUR, volume 1466 of Lecture Notes in Computer Science, pages 613–628. Springer, 1998. ISBN 3-540-64896-8. [17] J. Hughes. Generalising monads to arrows. Sci. Comput. Program., 37(1-3):67–111, 2000. [18] J. Hughes. Programming with arrows. In V. Vene and T. Uustalu, editors, Advanced Functional Programming, volume 3622 of Lecture Notes in Computer Science, pages 73–129. Springer, 2004. ISBN 3- 540-28540-7.