Skip to content

Instantly share code, notes, and snippets.

@dabd
Last active May 7, 2020 15:16
Show Gist options
  • Save dabd/ca4b2d043963ccd1819aa0a87be87f3c to your computer and use it in GitHub Desktop.
Save dabd/ca4b2d043963ccd1819aa0a87be87f3c to your computer and use it in GitHub Desktop.
5.3.1 Co-Kleisli morphisms
Definition 5.3.5. Let (C, ε, ν) be a comonad on C. A co-Kleisli morphism of C from X to Y is a
morphism CX → Y of C.
Here is a typical situation in science. Suppose that, during an experiment, we have a process
f taking an input x ∈ X and giving an output y ∈ Y. This could be for example a survey in
which we ask people of different age (X) what their political views are (Y). Suppose that we
repeat the experiment, feeding again the same input x to f . It could happen that this time we
get a different outcome than before, y
′ , y. For example, suppose a person of age x expresses
political view y. Another person of the same age x may express a different political view y
(this
may even happen by asking the same person twice, in different moments). The usual conclusion
that we draw, in science, is: X alone (for example, age alone) is not enough to determine Y. There
was some “hidden”, “extra” data that the process f has access to in order to determine Y. It
could depend on hidden information, it could depend on past outcomes, and so on. Therefore
a better mathematical model of the situation is not quite f : X → Y, but rather f : CX → Y,
where CX contains more information than just X, as specified by the comonad C.
Note that this is somewhat dual to Kleisli morphisms: there, functions were allowed to have
more possible outcomes. Here, they are allowed to depend on possibly more information.
Example 5.3.6 (several fields). A co-Kleisli morphism for the reader comonad of Example 5.3.1
is a map k : X × A → Y. We can view it as a map that, when fed x ∈ X, also needs to read
a a ∈ A to give its output. This can model the experimental situation of “hidden variables”
described above.
3The condition of local contractibility can be weakened, see [Hat02, Section 1.3].
162
5 Monads and comonads
An example in computer science is a function that needs an extra input in order to carry out
the computation, either via user interface (say, keyboard), or by having access to some external
environment. This motivates the name “reader comonad”.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment