
Hi! On Mon, Oct 11, 2004 at 02:19:45PM +0400, Serge D. Mechveliani wrote:
Dear Haskell implementors,
How do you think, is the program (1) equivalent to (2) in the meaning of Haskell-98 ?
(1) (\ x -> (if p x then foo (g x) else foo (h x)) where p ... g ... h ... foo ... )
(2) (\ x -> foo ((if p x then g x else h x) where p ... g ... h ... foo ... ) )
In general they are not, for exactly the reason you give:
The reason for this may be, for example, that the result printing of (f x) is more `lazy' in (2) than in (1): the part of foo may print immediately and (g x) or (h x) may print long after. This is a difference in behavior, it does not effect the computation meaning.
If p x == _|_ and foo _|_ /= _|_, then (1) does not equal (2).
I have a large program which is easily written in the style of (1), (and in many places it sets `case' instead of `if'). Annoyingly, it prints out in a not a lazy manner.
You get what you specify :-) Greetings, Carsten -- Carsten Schultz (2:38, 33:47), FB Mathematik, FU Berlin http://carsten.codimi.de/ PGP/GPG key on the pgp.net key servers, fingerprint on my home page.