Function programming is based[1]; that is, based on principles that allow a systematic and repeatable process for creating software. In this post I’

Functional Programming is Based

submited by
Style Pass
2023-03-14 17:30:03

Function programming is based[1]; that is, based on principles that allow a systematic and repeatable process for creating software. In this post I’m going illustrate this process with an example of summing the elements of a list, inspired by this conversation. We’ll mostly be looking at algebraic data types and structural recursion (which often uses pattern matching, but is not synonymous with it).

For me, a working functional programmer, this process is one of the main advantages of FP. It mean I can spend my mental cycles on understanding the problem, knowing that once I have done so the implementation follows in a straightforward way. The inverse also holds: if someone uses these principles to write code I can easily work out what problem it solves.

As the description suggests, they go together. If we use an algebraic data type to define data, we can then use structural recursion to manipulate that data.

Leave a Comment