[Haskell] Re: ST/STRef vs. IO/IORef

Wolfgang Jeltsch wolfgang at jeltsch.net
Thu Aug 4 04:29:23 EDT 2005

Am Mittwoch, 3. August 2005 19:07 schrieb Srinivas Nedunuri:
> [...]

> I have a bunch of ST code, and then somewhere in there I had the misfortune
> of needing to insert a file copy and bam I'm now stuck with the dang IO
> monad which goes and "infects" the entire program.

You can use something like

	myPureComputation :: String -> ST s Int

where the parameter denotes the file content.  Then you do something like 

		fileContent <- readFile "myFile"
		print $ runST $ myPureComputation fileContent

So you don't need to infect your ST computation with I/O the same way you 
often don't need to infect an ordinary pure calculation with I/O.

Or did you mean something different?

> [...]


More information about the Haskell mailing list