First Class File IO

Erik Zuurbier F.S.A.Zuurbier@inter.nl.net
Wed, 7 Jan 1998 00:30:01 +0100


>The following function is intended to be made available:
>
>  typeToString :: Dynamic -> String
>
>Is this what you wished for, Erik?
Looks good enough to me. Oops, I think your line:
  DynApply (x::a->b) (y::a) = dynamic (f x) :: b
should be
  DynApply (x::a->b) (y::a) = dynamic (x y) :: b



>
>2. If a particular file's type is simply not known (forgotten, that is),
> > will there be some utility program that can be used to reveal the type?
>
>No, for reason that it is not possible to write such a utility program.
>In general, one cannot (re)construct the type of the expression from the
>data that represents it (its graph).

I was a bit confused when I read this answer. It must be a misunderstanding.
What I meant was: say I find an old file in my filing system of which
I only know that it contains a Clean Dynamic. There is no documentation
of its type or its contents. Doesn't that sound familiar :-).
Your answer to my first question solves this problem: I just write a
little Clean program to read in the Dynamic, matching/unifying it with
an irrefutable type pattern. I then apply typeToString to it. That
reveals the type.

I understand that from the data alone, say a sequence of four bytes,
it is impossible to say whether it represents an Integer value, a String
or whatever else.

Case closed, I guess :-)