Skip to main content
1 of 2
Neel Krishnaswami
  • 9.2k
  • 1
  • 30
  • 54

This didn't fit in the comments, so I'm posting it as an answer.

Ignoring size issues, we can define a category as a set of objects, together with a family of sets of morphisms, with one set for each domain and codomain -- ie, as a dependent record:

$$\mathrm{Cat} = \sum \mathrm{Obj}:\mathrm{Set}.\;\sum \mathrm{Mor} : \mathrm{Obj} \times \mathrm{Obj} \to \mathrm{Set}.\; \ldots \mathit{category\; axioms} \ldots$$

So if you have a category $C \equiv (\mathrm{Obj}, \mathrm{Mor}, \ldots)$ and a monad $(T, \mu, \eta)$, the Kleisli category will be of the form $(O, (\lambda AB.\;\mathrm{Mor}(A, TB)), \ldots)$.

Then, the extension operator will be an operation whose type is $\prod A,B:O.\;\mathrm{Mor}(A, TB) \to \mathrm{Mor}(TA, TB)$, which can be defined in the obvious way, as $\lambda A\;B\;f.\;T(f);\mu_B$. Note that the objects for the domain and codomain come in as arguments, so there's no need to reconstruct them from the data of the function $f$.

(In fact, if you spell out the definition of functor for this setup, you'll see that even $T$ will be indexed, so its action on morphisms really ought to be written $T_{A,B}(f)$. I just left them out since these arguments are obvious from context.)

Neel Krishnaswami
  • 9.2k
  • 1
  • 30
  • 54