I am trying to understand I/O in haskell. I have trouble understanding
how it is referentially transperant ?

Consider a list of four elements [exp1,exp2,exp3,exp4] where exp's are
arbitary expressions (of type other than Request). Here one can
evaluate expression exp3 without evaluating exp1 and exp2. But this
does not hold true if the above mentioned list is of type [Request].
I have drawn this conclusion because Haskell Report 1.2 , pg. 70,
says,

        "Requests to the file systems are in general order-dependent;
        if i>j then the response to the ith request may depend on the
        jth request. In case of channel system the above ...."

Consider a request list, [req1,req2,req3,req4]. This means before
evaluating req3, I should have evaluated req1 and req2. Doesn't this
mean that there is some sequencing going on around? The sequencing is
due to the fact that req3 may depend on req1 and req2. 

Consider that main is,

         main resps = [req1,req2,req3,req4]
                      where req1 = ..
                            req2 = .... (tl resps) ....
                            req3 = .... (tl resps) ....
                            req4 = ..

As, req1,..,req4 are all evaluated in the environment with a binding for
resps, both (tl resps) in req2 and req3 should evaluate to same
expression (referential transperancy). But when req2 is evaluted,
resps = [response_to_request1] and when req3 is evaluated,
resps = [response_to_request1, response_to_request2]. 
Hence, (tl resps) in req2 and req3 donot evaluate to the same value. 
Isn't referential transperancy lost ? In other words, the binding
for resps keep on changing i.e. there is some side effect occuring
somewhere.

        This is the picture that I have drawn after reading Haskell
I/O. I may be wrong somewhere. Correct me if I am wrong. 

-Namrata Shah
([EMAIL PROTECTED])

        

Reply via email to