Haskell Workshop
Introduction for everyone
Introduction for everyone
( λx.x + 1 ) 2
[ x := 2 ] # applying 2
( λ[ x := 2 ].x + 1 )
( 2 + 1 )
3 # reduced to identity function
# Applications are left associative
'1' ( λx.x )( λy.y ) z
'2' ( ( λx.x )( λy.y ) ) z # rewrite as
'3' [ x := ( λy.y ) ] # apply from left to right
'4' ( λy.y ) z
'5' [ y := z ]
'6' z # reduced to identity
'7' # "z" is a free variable
# It is just a shorthand for nested Lambda
'1' λxy.x + y
'2' λx.λy.x + y
'3' λx.( λy.x + y )
# apply with x = 1 and y = 2
'1' ( λxy.x + y ) 1 2
'2' λx.( λy.x + y ) 1 2
'3' λ[ x := 1 ].( λy.x + y ) 2 # apply x = 1
'4' ( λy.1 + y ) 2
'5' ( λ[ y := 2 ].1 + y ) # apply y = 2
'6' 1 + 2
'7' 3
# Reached beta normal form (cannot reduce further)