Sat, 21 Jun 2003 17:34:59 +0100
naudts guido wrote:
> Take following function:
> f::Array Int Char -> (Array Int Char, Char)
> f array = (array1, c)
> where c = array!1
> array1 = array//[(2,'b')]
> and also following function:
> f::Direct_access_file -> (Direct_access_file, Char)
> f daf = (daf1, c)
> where c = getnext daf
> daf1 = set 2 'b'
> with a hypothetical format for the direct access file.
> Now I can certainly implement the first function in
> Haskell but not the second.
> Now the only difference between the two functions is
> the location of the data: in the first the data of the
> array are in RAM, in the second the data of the direct
> access file are on disk. There is no other difference.
> As far as referential integrity is concerened I don't
> see any difference too.
> So why can I implement the first function and not the
> second (well I can use direct access files but I have
> to change the type of my function.The problem is:
> I do not see why the location of data should have an
> influence here.
Haskell values are private to the program, while file contents may be
read and written by other processes.
Haskell computations can be deferred, omitted or duplicated so long as
the program's semantics are preserved, but I/O operations must be
performed as and when specified.
Glynn Clements <firstname.lastname@example.org>