package mirage-tc

  1. Overview
  2. Docs

Mirage type-classes

type 'a equal = 'a -> 'a -> bool

Equalities.

type 'a compare = 'a -> 'a -> int

Comparators.

type 'a hash = 'a -> int

Hashing.

type 'a reader = Mstruct.t -> 'a

Mstruct reader.

exception Read_error of string

Read_error can be raised by the reader type-classes.

type 'a size_of = 'a -> int

Compute the size of the written objects.

type 'a writer = 'a -> Cstruct.t -> Cstruct.t

Write a value to a cstruct buffer. Return a new buffer ready for the next write.

type 'a to_json = 'a -> Ezjsonm.value

JSON converters.

type 'a of_json = Ezjsonm.value -> 'a
module type S0 = sig ... end

Abstract Identifiers.

module type S1 = sig ... end

Abstract identifiers with one polymorphic parameter.

module type S2 = sig ... end

Abstract identifiers with two polymorphic parameters.

module type S3 = sig ... end

Abstract identifiers with two polymorphic parameters.

Combinators

type 'a t = (module S0 with type t = 'a)

The type-class of values of type 'a.

val list : 'a t -> 'a list t
val option : 'a t -> 'a option t
val pair : 'a t -> 'b t -> ('a * 'b) t
val triple : 'a t -> 'b t -> 'c t -> ('a * 'b * 'c) t
val unit : unit t
val int : int t
val int32 : int32 t
val int64 : int64 t
val string : string t
val cstruct : Cstruct.t t
val bool : bool t
val equal : 'a t -> 'a equal
val compare : 'a t -> 'a compare
val hash : 'a t -> 'a hash
val to_json : 'a t -> 'a to_json
val of_json : 'a t -> 'a of_json
val size_of : 'a t -> 'a size_of
val write : 'a t -> 'a writer
val read : 'a t -> 'a reader
val show : 'a t -> 'a -> string
val shows : 'a t -> 'a list -> string
val read_string : 'a t -> string -> 'a
val read_cstruct : 'a t -> Cstruct.t -> 'a
val write_string : 'a t -> 'a -> string
val write_cstruct : 'a t -> 'a -> Cstruct.t
val biject : 'a t -> ('a -> 'b) -> ('b -> 'a) -> 'b t

Builders

module Bin_prot0 (S : sig ... end) : S0 with type t = S.t

Build abstract identifiers.

module Bin_prot1 (S : sig ... end) : S1 with type 'a t = 'a S.t

Build abstract identifiers with a polymorphic parameters.

module Bin_prot2 (S : sig ... end) : S2 with type ('a, 'b) t = ('a, 'b) S.t

Build abstract identfiers with two polymorphic parameters.

module Bin_prot3 (S : sig ... end) : S3 with type ('a, 'b, 'c) t = ('a, 'b, 'c) S.t

Build abstract identfiers with three polymorphic parameters.

module App1 (F : S1) (X : S0) : S0 with type t = X.t F.t

Monorphize a type with one parameter.

module App2 (F : S2) (X : S0) (Y : S0) : S0 with type t = (X.t, Y.t) F.t

Monorphize a type with two parameters.

module App3 (F : S3) (X : S0) (Y : S0) (Z : S0) : S0 with type t = (X.t, Y.t, Z.t) F.t

Monorphize a type with three parameters.

Useful instances

module Bool : S0 with type t = bool
module String : S0 with type t = string
module Cstruct : S0 with type t = Cstruct.t
module Unit : S0 with type t = unit
module Option (A : S0) : S0 with type t = A.t option
module O1 : S1 with type 'a t = 'a option
module Pair (A : S0) (B : S0) : S0 with type t = A.t * B.t
module P2 : S2 with type ('a, 'b) t = 'a * 'b
module Triple (A : S0) (B : S0) (C : S0) : S0 with type t = A.t * B.t * C.t
module T3 : S3 with type ('a, 'b, 'c) t = 'a * 'b * 'c
module Int : S0 with type t = int
module Int32 : S0 with type t = int32
module Int64 : S0 with type t = int64
module List (A : S0) : S0 with type t = A.t list
module L1 : S1 with type 'a t = 'a list
module Set (A : S0) : S0 with type t = Set.Make(A).t
module Biject (A : S0) (B : sig ... end) : S0 with type t = B.t
module As_L0 (S : sig ... end) : S0 with type t := S.t

Manorphic list -like.

module As_L1 (S : sig ... end) : S1 with type 'a t := 'a S.t

Polymorphic list -like.

module As_AL1 (S : sig ... end) : S1 with type 'a t := 'a S.t

Association list -like.

Helpers

module Reader : sig ... end
module Writer : sig ... end
module Compare : sig ... end
module Equal : sig ... end
module Size_of : sig ... end
OCaml

Innovation. Community. Security.