[Haskell-cafe] Referential Transparency and Monads

Miguel Mitrofanov miguelimo38 at yandex.ru
Thu Apr 9 23:29:33 EDT 2009


On 10 Apr 2009, at 06:30, Jonathan Cast wrote:
>  do
>     s <- readFile "/my_file"
>     writeFile "/my_file" "Hello, world!\n"
>     threadDelay 10000 -- If you don't like threadDelay, just  
> substitute forcing
>                       -- an expensive thunk here
>     writeFile "/my_file" s
>
> As a function from initial state to final state, this program is just
> the identity;

No, since world state includes the user state itself, not just files  
contents.


More information about the Haskell-Cafe mailing list