↓ Skip to main content

Types and Functions 2: Currying

·171 words

It goes wrong fairly quickly when it comes to Chapter 04: Currying. It is unclear why you would want to do this 1 and how the code really works.

An additional problem is that many function definitions after this are written in curried form, like so:

// join :: String -> [String] -> String

It would have been nice if it was mentioned how to read these. To be fair it is in a way in the same Chapter 07 where I found the above signature: “Without fully understanding the details, you could always just view the last type as the return value.”

Digging through a bunch of mostly unhelpful documents, I figured out that you can take everything around the arrows as function arguments except for the last one.

So the join above is a function that takes a String and an array of Strings and returns a String.

Addendum: This also makes it easier to read the Ramda type signatures.


  1. I suspect that that will be a recurring theme. ↩︎

Alper Cugun
Author
Alper Cugun

Related

·14 words
Nice to find some more socially conscious and also quality rap in Germany.

·28 words
Truly, if you don’t throw hundreds of millions into the trash fire that is the big consultancies, there is no limit to what you can get done.