On 2009 Apr 9, at 22:47, Brandon S. Allbery KF8NH wrote:
> -- these implicitly are considered to return a modified RealWorld > readFile :: RealWorld -> (String,RealWorld) > writeFile :: RealWorld -> ((),RealWorld) > threadDelay :: RealWorld -> ((),RealWorld) > > main :: RealWorld -> ((),RealWorld) > main state = > case readFile state "/my_file" of > (s,state') -> > case writeFile state' "/my_file" "Hello, world!\n" of > (_,state'') -> > case threadDelay state'' 10000 of > (_,state'') -> writeFile "/my_file" s
Sorry, the last line should be: > (_,state''') -> writeFile state''' "/my_file" sThis code is nothing more nor less than the translation of Jonathan Cast's code, using a presumptive
> type IO a = State RealWorld ainto "linear" de-monadified code. Clearly the state is threaded into main, through all the calls, and the final state returned; the state threading is what maintains the referentially transparent model.
-- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] [email protected] system administrator [openafs,heimdal,too many hats] [email protected] electrical and computer engineering, carnegie mellon university KF8NH
PGP.sig
Description: This is a digitally signed message part
_______________________________________________ Haskell-Cafe mailing list [email protected] http://www.haskell.org/mailman/listinfo/haskell-cafe
