module Unmarshal:sig
..end
input_val
, similar in
functionality to the standard library function Marshal.from_channel
.
The main difference with Marshal.from_channel
is that
input_val
is able to apply transformation functions on the
values on the fly as they are read from the input channel.
Because it has an abstract representation of the type,
input_val
is able to catch some inconsistencies that
Marshal.from_channel
cannot. It is therefore "more" type-safe,
but only if it is always used in conditions where the static type
attributed to the result by the type-checker agrees with the
representation of the type passed as second argument to input_val
.
No such verification is done by this module (this would require
changes to the compiler).
The sanity checks are not the primary purpose of input_val
,
and it is possible for a bug where the representation of a value of
the wrong type is passed to input_val
to go undetected, just
as this can happen with Marshal.from_channel
.
type
t =
| |
Abstract |
| |
Structure of |
| |
Transform of |
| |
Return of |
| |
Dynamic of |
type
structure =
| |
Sum of |
|||
| |
Dependent_pair of |
|||
| |
Array of |
(* |
Type
t is used to describe the type of the data to be read and
the transformations to be applied to the data.
a must match the shape
of the representation of the type of the data being imported, or
input_val may report an error when the data doesn't match the
description.
| *) |
val input_val : Pervasives.in_channel -> t -> 'a
input_val c t
Read a value from the input channel c
, applying the transformations
described by t
.val null : Obj.t
null
(with the function ==
)
and avoid using any field that is equal to null
.val id : Obj.t -> Obj.t
val t_unit : t
val t_int : t
val t_string : t
val t_float : t
val t_bool : t
val t_int32 : t
val t_int64 : t
val t_nativeint : t
val t_record : t array -> t
val t_tuple : t array -> t
val t_list : t -> t
val t_ref : t -> t
val t_option : t -> t
val t_array : t -> t
val t_queue : t -> t
val t_hashtbl_unchangedhashs : t -> t -> t
val t_hashtbl_changedhashs : (int -> 'table) ->
('table -> 'key -> 'value -> unit) ->
t -> t -> t
val t_set_unchangedcompares : t -> t
val t_map_unchangedcompares : t -> t -> t
val register_custom : string -> (Pervasives.in_channel -> Obj.t) -> unit
val arch_sixtyfour : bool
val arch_bigendian : bool
val getword : Pervasives.in_channel -> Int32.t
val read8s : Pervasives.in_channel -> int
val read16s : Pervasives.in_channel -> int
val read32s : Pervasives.in_channel -> int
val read64s : Pervasives.in_channel -> int
val read8u : Pervasives.in_channel -> int
val read16u : Pervasives.in_channel -> int
val read32u : Pervasives.in_channel -> int
val read64u : Pervasives.in_channel -> int
val readblock : Pervasives.in_channel -> Obj.t -> int -> int -> unit
val readblock_rev : Pervasives.in_channel -> Obj.t -> int -> int -> unit