Re: 'a -> string ?

From: Xavier Leroy (Xavier.Leroy@inria.fr)
Date: Fri Oct 17 1997 - 10:59:46 MET DST


From: Xavier Leroy <Xavier.Leroy@inria.fr>
Message-Id: <199710170859.KAA29280@pauillac.inria.fr>
Subject: Re: 'a -> string ?
In-Reply-To: <199710161019.MAA04691@cosmos.imag.fr> from "GillesDfnx@mail.dotcom.fr" at "Oct 16, 97 12:19:19 pm"
To: GillesDfnx@mail.dotcom.fr
Date: Fri, 17 Oct 1997 10:59:46 +0200 (MET DST)

> I'm looking for an equivalent of
>
> val output_value : out_channel -> 'a -> unit
>
> that would output the representation of the element of type 'a into a
> 'string' instead of and 'out_channel' (for subsequent inclusion into a
> dbm database). I would like to avoid using a temp file followed by an
> 'input' call.

In the current release (OCaml 1.05), you can do that using
undocumented features, as follows:

        let output_value_to_string v = Obj.marshal(Obj.repr v)

The forthcoming release 1.06 will provide a nicer interface for this
feature.

Regards,

- Xavier Leroy



This archive was generated by hypermail 2b29 : Sun Jan 02 2000 - 11:58:12 MET