Currently browsing

Functional

Monads for Software Engineers

The term monad could sound weird to a software engineer because it comes from category theory. There’s plenty of related maths material around but let’s just forget about it and about the choice of that word (BTW am I the only one being triggered Leibniz memories from high-school philosophy classes?): I’m interested in a software engineering perspective on the topic and, since I couldn’t find an introductory one that was clear enough for me, I decided to take a dive in and build my own. What is a monad? Very, very shortly: a data structure implements a monad interface iff it defines some “lifted-up” functions sequencing operator (think of a functional “;“-like sequencing). So a monad itself is basically …

On Being “Functional”

There is more and more talk going on about functional programming nowadays; the paradigm is finally understood, accepted, implemented in most runtimes and used by many software engineers, in a more or less aware fashion (just think of JavaScript) and in a more or less hybrid form (just think of Scala). I say “finally” because functional programming has many useful properties, among which: It enables building and reusing components at the level of computation logic, which is a more fine-grained one than objects or modules. It enables a more declarative style that can reduce code size, enhance readability and improve maintainability. With its emphasis on pure functions, values and stateless logic, It helps reasoning and getting more aware about when state and …