Lightweight Typed Customizable Unmarshaling

Abstract

International audience1. Abstract The contribution of this work is threefold. First, we offer an OCaml unmarshaling algorithm that uses a lightweight type-directed de-scription of the expected structure of data to make consistency checks. The second contribution is the opportunity to specify func-tions to be systematically applied on values as they are being un-marshaled. Our third contribution is a type-safe layer for these functions and for the unmarshaling algorithm itself. 2. Description The standard OCaml unmarshaling function is input value: in channel → α. The aforementioned first contribution is a function descr input val with type in channel → descr → α. One value of type descr that can be passed as second argu-ment is Abstract, and then the behavior is exactly identical to input value. The programmer can provide as much information as (s)he wants for the additional consistency checks. For instance, (s)he can pass the value (t array Abstract) to specify that the value being read is an array of undescribed values. Our unmar-shaling algorithm maintains a cursor into the structure description, allowing it to know what the current loaded value should look like

    Similar works