by ncd · 10y ago · 0 comments
So in order to construct functions that accept more than one argument, you actually return successive functions that apply successive arguments, known as currying.
Does this kind of 1/arity have performance implications for Haskell? Does the compiler lower (or is it rise? inline?) the functions to produce efficient machine code?
connectWords : String -> String -> String
connectWords firstWord secondWord =
firstWord ++ secondWord let prefix = connectWords "Hello "
world = prefix "world"
bob = prefix "bob"
in ...
`world` is "Hello world", and `bob` is "Hello bob". That is the power of currying. A maybe more useful example is specifying the mapping function in `List.map` without supplying the list to map over. This allows you to use the same map with multiple lists. connectWords = \ firstWord -> \ secondWord -> firstWord ++ secondWord