Module Transform

module Transform: sig .. end

Pipeline of Transformations



type 'a printer = 'a CCFormat.printer 

Features

Set of features that characterize a logic, as a record of individual features

module Features: sig .. end

Single Transformation


type ('a, 'b, 'c, 'd) t = 
| Ex : ('a0, 'b0, 'c0, 'd0, 'st) inner -> ('a0, 'b0, 'c0, 'd0) t
Transformation of 'a to 'b, with reverse transformation from 'c to 'd. The transformation make choices by lazily returning several values. It is also allowed to store data in a internal "state" type, to be able to perform the reverse transformation.
type ('a, 'b, 'c, 'd, 'st) inner = {
   name : string; (*
name for the transformation, used for debug, CLI options, etc.
*)
   encode : 'a -> 'b * 'st;
   decode : 'st -> 'c -> 'd;
   input_spec : Features.t;
   map_spec : Features.t -> Features.t;
   mutable on_input : ('a -> unit) list;
   mutable on_encoded : ('b -> unit) list;
   mutable on_decoded : ('d -> unit) list;
   print_state : (Format.formatter -> 'st -> unit) option; (*
Debugging
*)
}
Transformation with explicit hidden state
type ('a, 'b, 'c, 'd) transformation = ('a, 'b, 'c, 'd) t 
Alias to Transform.t
val make : ?print:(Format.formatter -> 'st -> unit) ->
?on_input:('a -> unit) list ->
?on_encoded:('b -> unit) list ->
?on_decoded:('d -> unit) list ->
?input_spec:Features.t ->
?map_spec:(Features.t -> Features.t) ->
name:string ->
encode:('a -> 'b * 'st) ->
decode:('st -> 'c -> 'd) -> unit -> ('a, 'b, 'c, 'd) t
Constructor
val backward : name:string -> ('b -> 'c) -> ('a, 'a, 'b, 'c) t
backward f is the identity in the direct way, and the same as f in the way back
val nop : unit -> ('a, 'a, 'b, 'b) t
Transformation that does nothing
val on_encoded : ('a, 'b, 'c, 'd) t -> f:('b -> unit) -> unit
on_encoded tr ~f registers f to be called on every value obtained by encoding through tr
val on_input : ('a, 'b, 'c, 'd) t -> f:('a -> unit) -> unit

Pipeline of Transformations

Allows chaining the transformations in a type-safe way

module Pipe: sig .. end
val run : pipe:('a, 'b, 'c, 'd) Pipe.t -> 'a -> ('b * ('c -> 'd)) Lazy_list.t
run ~pipe x runs x through the pipe pipe, in a lazy way, and yields values of type 'b along with a conversion function back