| ▲ | taolson 3 hours ago | |
An example where this is useful is to help inline otherwise recursive functions, by writing the function to take some useful parameters first, then return a recursive function which takes the remaining parameters. This allows the function to be partially in-lined, resulting in better performance due to the specialization on the first parameters. For example, foldr: foldr f z = go
when called with (+) and 0 can be inlined togo xs = case xs of
which doesn't have to create a closure to pass around the function and zero value, and can subsequently inline (+), etc. | ||