Introduction to the course

This course

Self study

Organization

Getting help

Recalling Haskell

Functions vs. Actions

Programming with IO

code

Referential transparency

Referential transparency in practice

Evaluation orders

Observing evaluations in Haskell

Lazy evaluation: skipping unnecessary computations

Lazy evaluation: programming style

Lazy evaluation: when is a value "needed"?

Lazy evaluation: at most once?

ff :: Integer -> Integer
ff x = (x - 2) * 10

foo :: Integer -> Integer
foo x = ff x + ff x

bar :: Integer -> Integer -> Integer
bar x y = ff 17 + x + y

testBar =  bar 1 2 + bar 3 4

Lazy evaluation: infinite lists

Lazy evaluation: infinite lists exercises

Lazy evaluation: infinite data structures

Lazy evaluation: conclusions

Lazy evaluation
Avoid unnecessary computations (a different programming style)
It provides error recovery
It allows to describe infinity data structures
It can make programs more modular
It is hard to do complexity analysis
It is not suitable for time-critical operations

Type classes

code

Focus of this course

Typical embedded language