flâneur — a map of the web's best reading

Kleisli Categories | Bartosz Milewski's Programming Cafe

bartoszmilewski.com · 5,253 words · saved by 1 readers

In the previous installment of Categories for Programmers, Categories Great and Small, I gave a few examples of simple categories. In this installment we’ll work through a more advanced example. If you’re new to the series, here’s the Table of Contents. You’ve seen how to model types and pure functions as a category. I also mentioned that there is a way to model side effects, or non-pure functions, in category theory. Let’s have a look at one such example: functions that log or trace their execution. Something that, in an imperative language, would likely be implemented by mutating some global state, as in: You know that this is not a pure function, because its memoized version would fail to produce a log. This function has side effects. In modern programming, we try to stay away from global mutable state as much as possible — if only because of the complications of concurrency. And you would never put code like this in a library. Fortunately for us, it’s possible to make this function

Kleisli Categories | Bartosz Milewski's Programming Cafe Home About Bartosz Milewski's Programming Cafe Category Theory, Haskell, Concurrency, C++ December 23, 2014 Kleisli Categories Posted by Bartosz Milewski under C++ , Category Theory , Haskell [34] Comments In the previous installment of Categories for Programmers, Categories Great and Small , I gave a few examples of simple categories. In this installment we’ll work through a more advanced example. If you’re new to the series, here’s the Table of Contents . Composition of Logs You’ve seen how to model ty

Explore this link on the map →

related reading