From mutable loops to immutable folds

When we ask of key-features of functional programming, you will probably hear two things most often. Immutability and recursion. But why is that so? As Immutability also becomes more important in OO languages you will probably find a lot of reason for that one, but why are recursive functions so...

Continue reading ...

Understanding bind

In Understanding map we learned that implementing a map function is what we call a Functor. In Applicative Functors we extended that idea with the return and apply function. The next important function in our toolset is the bind function. Monads The combination of return and bind is what we...

Continue reading ...

Applicative Functors

In my previous blog "Understanding map" I introduced the map function and described that implementing map and fulfilling two laws we get what we call a Functor. As we already can guess from the title. An Applicative Functor is some sort of extension to that idea. Problem with map It...

Continue reading ...

Understanding map

One important function in functional programming is the map function. When I learned F# I must admit that I had some problems first, understanding it. The problem was, I already knew the map function from dozens of other languages. Or to say it correctly, I mostly learned a wrong explanation...

Continue reading ...

Exceptions are Evil

Most people today agree that null is evil, and they try to get rid of them. One technique that most people prefer is to throw an exception in the case of an error, or if we cannot return a valid value from a function. The problem is, exceptions are not...

Continue reading ...

Higher-kinded Polymorphism: What is it, why you want it

One aspect of a programming language that is often noted as important is the idea of Polymorphism. But there doesn't exists just one type of polymorphism. In functional languages Parametric Polymorphism (aka Generics) is often used. Haskell was the first language that introduced "Higher-kinded polymorphism". Sadly, F# don't support this...

Continue reading ...

null is Evil

Tony Hoare once said: I call it my billion-dollar mistake. It was the invention of the null reference in 1965. So, why did he added "null" in the first place? Why was it such a big mistake. And if it is such a big mistake, what are the alternatives? The...

Continue reading ...

Understanding Immutability and Pure Functions (for OOP)

One important concept in functional programming is immutability. But also in object-oriented programming immutability and so called immutable objects getting more attention. The problem that I see especially from object-oriented programmers are really bad explanations. A lot of explanation I had see described it like this: Just create a class...

Continue reading ...

Introduction to F#

When I remember the first time I looked at functional(-first) languages like F#, ML, Haskell and others. The typical reaction that I had, and I always see from other people is: This is unreadable, it must be hard to read, it feels complicated and hard. After spending some time in...

Continue reading ...

Applying Structured Programming

In my previous post about Structured Programming I talked about that basic looping constructs, fold and so on are basically just still to powerful. In the sense of readability we should try to eliminate them with more specific ones. In this post i go through a toy example to show...

Continue reading ...