Programming in Haskell by Hutton says
When evaluating an expression, in what order should the reductions be performed? One common strategy, known as innermost evaluation, is to always choose a redex that is innermost, in the sense that it contains no other redex. If there is more than one innermost redex, by convention we choose the one that begins at the leftmost position in the expression.
Another common strategy for evaluating an expression, dual to innermost evaluation, is to always choose a redex that is outermost, in the sense that it is contained in no other redex. If there is more than one such redex then as previously we choose that which begins at the leftmost position. Not surprisingly, this evaluation strategy is known as outermost evaluation.
In partial application of a function, for example, mult(3)(4)
, where mult
is defined as
mult :: (Int,Int) -> Int
mult (x,y) = x * y
innermost evaluation will first evaluate mult(3)
as \y->3*y
, and then evaluate (\y->3*y)4
.
How will outermost evaluation evaluate mult(3)(4)
?
In application of a curried function, for example, mult'(3)(4)
, where
mult' :: Int -> Int -> Int
mult' x = \y -> x * y
innermost evaluation will first evaluate mult'(3)
as \y->3*y
, and then evaluate (\y->3*y)4
.
How will outermost evaluation evaluate mult'(3)(4)
?