
On Tue, 17 Mar 2009 14:32:24 +0530, Girish Bhat
Hi Everyone,
I was going through the classic Hudak paper "Conception, Evolution, and Application of Functional Programming". Probably the most valuable part is towards the end where he talks about how state is represented in Haskell. On Page 48 of the PDF (page 406 of the ACM Computing survey volume), he gives the following equations "For expository purposes we would like to make the state as implicit as possible, and thus we express the result as a composition of higher-order functions. To facilitate this and to make the result look as much like the original program as possible, we define the following higher-order infix operators and functions":
1 f:=g =\s -> +fs(gs)
2? ?f;g =\s -> g(fs)=\s-+fs(gs)
3? ?f;g =\s -> g(fs)
4 goto f = f
5 f+‘g=\s-+fs+gs
6 f<‘g=\s-+fs
7 if’ p c = \s + (if (p s) then (c s) else s)
Unfortunately I am unable to parse/understand what he is doing here. My closure understanding too seems to be wonky. :) Would someone be kind enough to translate each of the above into plain english and explain how to read such eqns in the future?
(FYI, there is a copy of the above-mentioned paper that doesn't require an ACM account available at http://www.cs.berkeley.edu/~jcondit/pl-prelim/hudak89functional.pdf.) Hudak is just defining a series of higher-order infix operators and functions. (You have made some notational errors in the above-mentioned notation, so I am revising it to match the paper as below.) A backslash denotes a lambda symbol; i.e., whatever immediately follows the lambda is a parameter in the following equation. Specifically:
1 f := g =\s -> f s (g s)
In other words, the infix operator ':=' works between functions f and g such that lambda s -> f s (g s).
2 f ; g = \s -> g (f s)
In other words, the infix operator ';' works between functions f and g such that lambda s -> g (f s).
3? ?f;g =\s -> g(fs)
I couldn't find this equation on p. 406 of the volume; where did you find it?
4 goto f = f
In other words, the function "goto" applied to f is defined as simply f.
5 f +' g = \s -> f s + g s
In other words, the infix operator '+'' works between functions f and g such that lambda s -> f s + g s.
6 f <' g = \s -> f s < g s
In other words, the infix operator '<'' works between functions f and g such that lambda s -> f s < g s.
7 if' p c = \s -> (if (p s) then (c s) else s)
In other words, the function "if'" applied to functions p and c is such that lambda p c -> (if (p s) then (c s) else s). Hope this helps.... -- Benjamin L. Russell -- Benjamin L. Russell / DekuDekuplex at Yahoo dot com http://dekudekuplex.wordpress.com/ Translator/Interpreter / Mobile: +011 81 80-3603-6725 "Furuike ya, kawazu tobikomu mizu no oto." -- Matsuo Basho^