Learning programming with C, functions were a very special thing for me in my early days. Though there were function pointers back then, didn’t use those much and I had this idea that functions are very different from data.
After being introduced to closures and lambdas, functions started becoming less special, with the ability to use them as first class citizens they seemed very much like data as I could pass those around like values, could create higher order functions.
After spending some time with Haskell it became a lot more clear that functions and data aren’t very different. And by function here I mean functions without any funny business aka pure functions. For anyone not knowing what pure functions are, they are like Matemathical functions which always return the same value for the same set of arguments.
My purpose in this post is to try explaining why functions are very much like data. The code examples will be in Haskell but they will be simple enough to be understandable to anyone having decent programming experience.