Pure File Reading (was: Dealing with configuration data)

Yoann Padioleau Yoann.Padioleau@irisa.fr
26 Sep 2002 15:52:47 +0200

Lars Lundgren <d95lars@dtek.chalmers.se> writes:

> On 26 Sep 2002, Yoann Padioleau wrote:
> > Koen Claessen <koen@cs.chalmers.se> writes:
> > 
> > i find your idea very good.
> > indeed for the library GetOpt, the argument of a program never change so it
> >  make sense to make this library without using IO monad, same for argv and for the enviroment.
> > for openFile it seems harder, it would require to have a lock on the file
> >  to be sure that no one modify the file, same for a webpage.
> > 
> No, not at all. All that is required is to make sure all calls to openFile
> f returns the same string, i.e the contents of the file when it was read
> the first time.

yes you are right. but it requires to change
the name of the function to have Once appended to it.
so in the Prelude, we should have 2 version of the same kind of fonction,
one pure such as readFileOnce with a cool type, and one such as readFile with
an Io type.
Sounds good idea to me, cos many programs require just to read
 a file one time.
i dont know if practically it is useful. after all we can do
 all the IO stuff in the main, and then continue in a pure world.
 dont know if it is useful to read a file in the middle of a pure function.

> /Lars L

          Yoann  Padioleau,  INSA de Rennes, France,
Opinions expressed here are only mine. Je n'écris qu'à titre personnel.
**____   Get Free. Be Smart.  Simply use Linux and Free Software.   ____**