<<
>>

From categorical point of view, functional programming consists of representing a program as a morphism in a category: f: X → Y, where X is "input", and Y is "output". (The advantage of such a model is that we can immerse all our statement regarding programs into a very stable and sound category theory; we can vary the nature of objects and categories, change the logic of the underlying topos and still be 100% aware of what we are talking about. E.g. instead of "fuzzy logic" we can use intuitionistic logic and Kripke-Joyal semantics.)

Certain programming activities seem not to fit into this model: e.g. exceptions and side effect.

To deal with exceptions, one solution is to introduce a NullObject, or a NaN numeric value. For instance, if our function is not defined on the whole domain X, we can extend it to taking values in (Y+Null), as in Exception Monad.

To deal with stateful functions, we need to apply the notion of State Machine Monad.