Another throwaway comment that sort of blew my mind recently; I am making my way through Haskell For Dilettantes and I’m very much enjoying the lectures and exercises. A sidebar video (Part 4) explains that ‘space’ performs function application. The example given is

addTwoInts :: Int  Int  Int
addTwoInts x y = x + y

addTwoInts 5 7

In another language one might write addTwoInts(5, 7) but due to partial application (currying) one can write this as a function that takes one argument returning a function that takes one argument; addTwoInts(5)(7). That first part is achieved in Haskell by writing addTwoInts 5, or the entire thing very equivalently by replacing all the runs of parentheses with a space (!).

addTwoInts(5)(7) === addTwoInts 5 7

which means that the space performs the operation of applying the function, in the way that parentheses do in some other languages.

I had never thought of it that way, even though I’m familiar with the idea of the ‘functions returning functions’ paradigm.

One other thing that caught my attention early on was that variable assignment is also function assignment…

x = 3

is a “function which takes no arguments and returns the value 3” (!).

Maybe these are things one learns when being taught such a language formally, but as a self-directed learner of this it’s fascinating to learn them after so much of the basic syntax and grammar. Great stuff.