Freyd is Kleisli, for Arrows

Arrows have been introduced in functional programming as generalisations of monads. They also generalise comonads. Fundamental structures associated with (co)monads are Kleisli categories and categories of (Eilenberg-Moore) algebras. Hence it makes sense to ask if there are analogous structures for Arrows. In this short note we shall take first steps in this direction, and identify for instance the Freyd category that is commonly associated with an Arrow as a Kleisli category.


Arrows have been introduced by Hughes [4] as generalisation of monads, in order to capture a common interface for non-trivial programs such as parsers. S e e also [7, 5, 13, 1] for more applications.
From a categorical point of view, Arrows have long been considered as an alternative formulation of the (older) concept of Freyd category, from [10]. Recently, an alternative categorical description of Arrows has emerged [3], as a monoid in a category of bifunctors Cop x C ^ S ets. This description is closer to the functional one, and enables a precise formulation of the one-to-one relationship between Arrows and Freyd categories, s e e [3] for details.
This setting of Arrows-as-monoids forms the starting point for the investigations in this paper. It extends the familiar description of monads-as-monoids (see [6,VII.3]) and com onads-asmonoids. Since Kleisli categories and categories of (Eilenberg-Moore) algebras are fundamental constructions for monads and comonads, we ask ourselves the obvious question: are there analogous constructions for Arrows?
In this note we shall give first answers, which are formulated at a high level of abstraction, touching upon a 2-categorical description (like in [11,9]). Concrete examples are missing at this stageapart from examples that com e from (co)monads. What w e do is formulate notions of algebra and Kleisli category for an Arrow, and illustrate that they are reasonable.
In particular, the one-to-one correspondence from Arrows to Freyd categories [3] is identified as the Kleisli construction for Arrows; hence the title "Freyd is Kleisli". For this notion of Kleisli construction w e have two justifications: 1) for Arrows induced by (co)monads, it coincides with the (usual) Kleisli construction for (co)monads; 2) it is characterised as a suitable left 2-adjoint, which is also the ca se for (co)monads [11]. In the course w e extend the notion of Arrows to be defined on Freyd categories, which leads to som e additional 2-categorical accounts.
It is straightforward to extend all the notions and results to enriched settings. That is, an Arrow is now a bifunctor Cop x C ^ V (instead of Cop x C ^ Sets) where V is a symmetric monoidal closed category and C is V-enriched. It subsum es for example an Arrow Cop x C ^ C when C is 1 Also part-tim e at Technical University Eindhoven, NL. 2Part of this w ork was done during the authors' stay at Research Center for Verification and Semantics, National Institute of Advanced Industrial Science and Technology, Japan. They are grateful for the hospitality.
Cartesian closed. This extension is not purely of technical interest: most notions of computations are found in enriched settings such as by cpo's and not in Sets. However in this paper w e stick to the non-enriched setting for the sake of simplicity of presentation. This paper is not self-contained. We shall assum e familiarity with earlier work on Arrows and their categorical semantics. We briefly recall notation and equations for Arrows in Section 2, together with the main results of [3]: "Arrows as monoids" and "Arrows are Freyd categories". In Section 3 the notion of Arrow-algebras is introduced and justified. Then we shall identify the construction of a Freyd category associated with an Arrow as a Kleisli construction in Section 4. Only at this point w e start using a 2-categorical language. We conclude in Section 5.

As introduced in [4]
, an Arrow is in the notation of the programming language Haskell a type class of the form: class Arrow A where arr It describes an Arrow as a binary operation (X ,Y ) ^ A X Y -which we shall often write with brackets as A (X , Y )-together with three operations arr, >>> and first. T hese operations should satisfy the following equations.

A strong monad (T, n,M, st) on a category C with finite products induces an Arrow T : Cop x C ^ S ets by (X, Y ) ^ HomC(X, T Y ). For instance its operator first is given by firstZ(a) = st o (a x Z ). Similarly, for a comonad (G ,e, 6) w e write G for the Arrow given by (X ,Y ) ^ HomC(GX, Y ). And in ca se we have both a strong monad T a nd a comonad G, together with a distributive law A: GT ^ TG we write the associated Arrow as (G ,T). It is given by (X, Y ) ^ HomC(G X ,T Y ).
The following definition gives the obvious way to associate a category of "computations" with an Arrow.

Definition 1
For an Arrow A : Cop x C ^ S ets, with operations arr, > » and first, we define an associated category CA with objects X e C and morphisms X ^ Y given by elements of the set A (X , Y ). Identities and composition are given by arr and > » in the obvious manner.
We then have a functor JA: C ^ CA given by arr. This forms an instance of a Freyd category [8].
For example, the pre-monoidal structure IE of CA comes from the operation first; the functor JA preserves pre-monoidal structures on-the-nose.

For an Arrow induced by a (co)monad, the associated Freyd category CA coincides with the (co)Kleisli category for the (co)monad in a usual sen se. For the Arrow (G, T ) induced by a monad T , a comonad G and a distributive law GT ^ TG, the mapping yields what is called the bi-Kleisli
category used e.g. in [12].

Theorem 2 (Theorem 5.4, [3])
For a locally small category C with finite products, there is a oneto-one correspondence between 1. Arrows A on C; 2. Locally small Freyd categories C ^ D.

EILENBERG-MOORE ALGEBRAS FOR ARROWS
In this section w e shall define the notion of Eilenberg-Moore algebras for Arrows. Its justification is made in two ways: 1) for Arrows induced by (co)monads it coincides with a variant of the usual notion of (co)algebras; 2) an Arrow-algebra is the sam e thing as a retraction of a Kleisli category, much like for monads.

Let us start by the situation for monads. We shall understand (Eilenberg-Moore) algebras (and coalgebras) in 2-categorical style as natural transformations. This means that an algebra for a monad (T,n,M) on a category C is a map p : T ^ idC satisfying the familiar equations p o n = id and p o T p = p o m.
Since such a monad T is the sam e thing as a monoid in the category of endofunctors C ^ Cwith monoidal structure given by functor composition and identity functor-we may write these monad equations as diagrams:

idc -> T i -------------T < g> T = T 2 p p ® p = p o Tp idc = idc ® idc
When T is strong we might as well require a coherence condition with its strength. Namely, for each X, Y e C, Recalling that an Arrow is also a monoid-now in the category of bifunctors-w e are led to the following notion.

Definition 3 Let A : Cop x C ^ S ets be an Arrow. An algebra for this Arrow is a natural transformation x : A ^ Hom such that:
It is compatible with arr and » . That is, the following diagrams commute.

arr > > H om ------------> A
It is compatible with first. That is, the following diagram commutes for each X, Y, Z e C. In elementary terms this means that an algebra x satisfies the following three equations.

Here the equality (*) is because x is compatible with first given by first(a) = st o (a x id); (f) is becau se of the naturality of x.
Verification of the multiplication law is more subtle. The definition of x in this proof su ggests that the Yoneda Lemma is applicable. We have chosen to write out the proof directly, for clarity.

x o T(x) = x(id) o x(arr(T(x))) = x(arr(T(x)) >>> id) = x(M o T(id) o n o T(x)) = x(T (x)) = x(M o T(n o x) o id) = x(arr(x) >>> id) = x(id) o x(arr(x)) = x(id) o x(id) = x(id >>> id) = x(M o T(id) o id
There is a dual result for comonads. This shows that Arrow-algebras form a common generalisation of monad algebras and comonad coalgebras. The proof is similar to the one above, and left to the reader.

Proposition 5 For a comonad G there is a bijective correspondence between comonadcoalgebras id ^ G and Arrow-algebras G ^ Hom for the corresponding Arrow G. □
We can even extend such results to bialgebras.

Proof. We shall only give the essentials, and leave details to the reader. Assum e a A-bialgebra
T ==> id G, where by definition the following diagram commutes.

We obtain an Arrow-algebra (w ,é)i (T,G) ^ Hom by (w ,é)(a) = w o a o é-It satisfies the required equations.
In the reverse direction, assum e an Arrow-algebra x

Lemma 8 MSFP '06
We claim that the previous lemma justifies our notion of Eilenberg-Moore algebras for Arrows, becau se for monads w e have an analogous characterisation.

For monads and comonads, the Kleisli construction is characterised 2-categorically as a certain left 2-adjoint [11]. In this section we show that the (bijective) mapping A ^ (C ^ CA) in the last section-from an Arrow to a Freyd category-allows for a similar 2-categorical characterisation.
Therefore the bijective mapping is justifiably called the Kleisli construction for Arrows. In its course the notion of Arrows is extended to be defined on Freyd categories in general, instead of on categories with finite products. We will also make som e additional accounts on the 2-categorical properties of this extended notion of Arrows.
Let us recall the situation for monads. The Kleisli construction is described in the following 2adjunction, as the left 2-adjoint of the canonical "insertion" 2-functor Ins.
Ins C a t^^T * M nd(C at*) Here the 2-category M nd(C at*) is such that:2 2-cell a : (H, a) ^ (H ',a '), is a natural transformation a : H ^ H ' which is compatible  with a and a' in a suitable sen se.

The functor Ins is a canonical one mapping an object C to (C,id). The functor O of the Kleisli construction maps an object (C ,T ) to the Kleisli category CT.
We shall do the sam e 2-categorical business for Arrows. Let us denote by F P C a t the 2-category of categories with finite products. We may try to get a functor KX : A rr(F P C at) ^ F P C a t for 2The notation M n d ( C a t _ ) comes from [11]. The 2-category C a t * is obtained from C a t by reversing 2-cells. The constructor M n d is actually a 2-functor which maps a 2-category C to the 2-category of m onads on C.
F r e y d is K le isli, fo r A rro w s a suitably defined A rr(F P C a t), which maps (C,A) to CA. However, the category CA does not necessarily have finite products: it has only a weaker structure of a Freyd category. This is the sam e difficulty which occurs already when we try to get the 2-adjunction (11) for strong monads.

This problem is mended by considering Arrows on Freyd categories. Hence the 2-adjunction (11) for Arrows would look as follows.
Ins F r e y d^ ^ A rr (Freyd)

KX
The definition of Arrows on Freyd categories is just the sam e as on categories with finite products, except for the conditions on first. Recall that in a Freyd category C i K, K has a pre-monoidal structure which w e denote by IE.

Definition 9 (Arrows on Freyd ca teg o ries) An A rro w on a Freyd category C i K is a monoid A < g> A i A Hom in the monoidal category [Kop x K, Sets] o f bifunctors, equipped with: for each X ,Y ,Z e K, firstXjYjZ : A(X , Y ) i A (X E Z ,Y E Z ) ,
which is natural in X, Y and dinatural in Z . The operations should satisfy the following equations.

Let us continue by describing ingredients of the adjunction (12).
The 2-category Freyd of Freyd categories is defined in the following obvious way.
• An object is a Freyd category C i K. •

The 2-category A rr (Freyd) of Arrows on Freyd categories is as follows.
• An object is a pair (C i K, A) of a Freyd category an Arrow A on that.  1-cell (F, H, a) : (C i K ,A ) i (D i L ,B ) induces a functor H : K A i LB such that: H X = H X on objects and H ƒ = aX Y(ƒ) on morphisms. • A 2-cell (a, p) is mapped to (a, p), where a component px is given by arr(px ). The naturality of p amounts to the coherence condition (13).

The 2-functor K : A rr(Freyd) i Freyd is essentially the Kleisli construction for Arrows in
Theorem 10 We have a 2-adjunction K H Ins : Arr (Freyd) i Freyd as in Diagram (12).

Theorem 11
The bijective correspondence in Theorem 2-between Freyd categories and Arrows on categories with finite products-extends to an isomorphism between 2-categories Freyd and A rr(F P C at) in an obvious way.
A rr F r e y d^_____A rr(F P C at) □ In Diagram (11) for Monads, the insertion functor Ins has a right 2-adjoint given by the obvious forgetful functor. This is also the ca se for Arrows. (14)  In particular, the Kleisli category for an Arrow turns out to be the Freyd category that corresponds to the given Arrow one-to-one. This situation is put clearly in 2-categorical terms, accompanied with som e additional observations.

Proposition 12 Each o f the "insertion" 2-functors in Diagram
The definition of Arrow-algebras in this paper we do not consider fully satisfactory. We might expect an algebra carried by specific object(s In [8] Freyd categories are shown to be equivalent to the fibrational notion of K-categories. The relation between K-categories and the current work is yet to be elaborated.