[<<][compsci][>>][..]
Mon May 9 09:32:38 EDT 2011

Haskell: functions vs. structures

Something funny happens when data structures are immutable: data and
code become more alike.

The difference between a (immutable) structure and a (pure) function
is that a structure is like a function where there is a
time-disconnect and multiplicity-disconnect between call and function
entry, meaning that data pasted in a structure will be interpreted
later, and possibly multiple times.  Data pasted in a function will be
interpreted immediately and only once.

If data structures are consumed only once, and the context of data
interpretation is explicit, the difference almost disappears and it is
often possible to re-arrange code such that constructor/deconstructor
pairs can be simplified into function calls.  This is called
deforestation[1].

[1] http://homepages.inf.ed.ac.uk/wadler/topics/deforestation.html



[Reply][About]
[<<][compsci][>>][..]