Frama-C API - Datatype
A datatype provides useful values for types. It is a high-level API on top of module Type
.
Type declarations
type 'a t = private {
equal : 'a -> 'a -> bool;
compare : 'a -> 'a -> int;
hash : 'a -> int;
copy : 'a -> 'a;
pretty : Stdlib.Format.formatter -> 'a -> unit;
mem_project : (Project_skeleton.t -> bool) -> 'a -> bool;
}
Values associated to each datatype. Some others are provided directly in module Type
.
module type Ty = sig ... end
A type with its type value.
module type S_no_copy = sig ... end
All values associated to a datatype, excepted copy
.
module type S = sig ... end
All values associated to a datatype.
Getters from a type value
val equal : 'a Type.t -> 'a -> 'a -> bool
val compare : 'a Type.t -> 'a -> 'a -> int
val hash : 'a Type.t -> 'a -> int
val copy : 'a Type.t -> 'a -> 'a
val pretty : 'a Type.t -> Stdlib.Format.formatter -> 'a -> unit
val mem_project : 'a Type.t -> (Project_skeleton.t -> bool) -> 'a -> bool
Easy builders
Must be used if you want to implement a required function by fun x -> x
. Only useful for implementing rehash
and copy
.
Must be used for equal
in order to implement it by compare x y = 0
(with your own compare
function).
val never_any_project : (Project_skeleton.t -> bool) -> 'a -> bool
Must be used for mem_project
if values of your type does never contain any project.
Each values in these modules are undefined. The usual way to use it is: module X: Datatype.S = struct include Undefined type t = ... let reprs = ... let name = ... let mem_project = ... (* Usually, Datatype.never_any_project *) (* define only useful functions for this datatype *) end
module Serializable_undefined : Undefined
Same as Undefined
, but the type is supposed to be marshallable by the standard OCaml way (in particular, no hash-consing or projects inside the type).
Generic builders
module type Make_input = sig ... end
Input signature of Make
and Make_with_collections
. Values to implement in order to get a datatype. Feel free to use easy builders (see above) for easy implementation.
module type Functor_info = sig ... end
Additional info for building Set
, Map
and Hashtbl
.
module type Set = sig ... end
A standard OCaml set signature extended with datatype operations.
module type Map = sig ... end
A standard OCaml map signature extended with datatype operations.
module type Hashtbl_with_descr = sig ... end
Marshallable collectors with hashtbl-like interface.
module type Hashtbl = sig ... end
A standard OCaml hashtbl signature extended with datatype operations.
module type S_with_collections = sig ... end
A datatype for a type t
extended with predefined set, map and hashtbl over t
.
module Make_with_collections (X : Make_input) : S_with_collections with type t = X.t
Generic comparable datatype builder: functions equal
, compare
and hash
must not be undefined
.
module With_collections (X : S) (_ : Functor_info) : S_with_collections with type t = X.t
Add sets, maps and hashtables modules to an existing datatype, provided the equal
, compare
and hash
functions are not undefined
.
Predefined datatype
module Unit : S_with_collections with type t = unit
val unit : unit Type.t
module Bool : S_with_collections with type t = bool
val bool : bool Type.t
module Int : S_with_collections with type t = int
val int : int Type.t
module Int32 : S_with_collections with type t = int32
val int32 : int32 Type.t
module Int64 : S_with_collections with type t = int64
val int64 : int64 Type.t
module Nativeint : S_with_collections with type t = nativeint
val nativeint : nativeint Type.t
module Float : S_with_collections with type t = float
val float : float Type.t
module Char : S_with_collections with type t = char
val char : char Type.t
module String : S_with_collections with type t = string
val string : string Type.t
val formatter : Stdlib.Format.formatter Type.t
module Integer : S_with_collections with type t = Integer.t
module Filepath : sig ... end
Type-safe strings representing normalized filepaths. See module Filepath.Normalized
.
val filepath : Filepath.t Type.t
Generic functors for polymorphic types
module type Polymorphic = sig ... end
Output signature of Polymorphic
.
module Polymorphic (P : sig ... end) : Polymorphic with type 'a poly = 'a P.t
Functor for polymorphic types with only 1 type variable.
module type Polymorphic2 = sig ... end
Output signature of Polymorphic2
.
module Polymorphic2 (P : sig ... end) : Polymorphic2 with type ('a, 'b) poly = ('a, 'b) P.t
Functor for polymorphic types with 2 type variables.
module type Polymorphic3 = sig ... end
Output signature of Polymorphic3
.
module Polymorphic3 (P : sig ... end) : Polymorphic3 with type ('a, 'b, 'c) poly = ('a, 'b, 'c) P.t
Functor for polymorphic types with 3 type variables.
module type Polymorphic4 = sig ... end
Output signature of Polymorphic4
.
module Polymorphic4 (P : sig ... end) : Polymorphic4 with type ('a, 'b, 'c, 'd) poly = ('a, 'b, 'c, 'd) P.t
Functor for polymorphic types with 4 type variables.
Predefined functors for polymorphic types
module Poly_pair : Polymorphic2 with type ('a, 'b) poly = 'a * 'b
module Pair_with_collections (T1 : S) (T2 : S) (_ : Functor_info) : S_with_collections with type t = T1.t * T2.t
module Poly_ref : Polymorphic with type 'a poly = 'a Stdlib.ref
module Poly_option : Polymorphic with type 'a poly = 'a option
module Option_with_collections (T : S) (_ : Functor_info) : S_with_collections with type t = T.t option
module Poly_list : Polymorphic with type 'a poly = 'a list
module List_with_collections (T : S) (_ : Functor_info) : S_with_collections with type t = T.t list
module Poly_array : Polymorphic with type 'a poly = 'a array
module Array_with_collections (T : S) (_ : Functor_info) : S_with_collections with type t = T.t array
module Poly_queue : Polymorphic with type 'a poly = 'a Stdlib.Queue.t
module Triple_with_collections (T1 : S) (T2 : S) (T3 : S) (_ : Functor_info) : S_with_collections with type t = T1.t * T2.t * T3.t
optlabel_func lab dft ty1 ty2
is equivalent to func ~label:(lab, Some dft) ty1 ty2
val func2 : ?label1:(string * (unit -> 'a) option) -> 'a Type.t -> ?label2:(string * (unit -> 'b) option) -> 'b Type.t -> 'c Type.t -> ('a -> 'b -> 'c) Type.t
val func3 : ?label1:(string * (unit -> 'a) option) -> 'a Type.t -> ?label2:(string * (unit -> 'b) option) -> 'b Type.t -> ?label3:(string * (unit -> 'c) option) -> 'c Type.t -> 'd Type.t -> ('a -> 'b -> 'c -> 'd) Type.t
module type Sub_caml_weak_hashtbl = sig ... end
module Caml_weak_hashtbl (D : S) : sig ... end