package bap-std

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type

Variants of values.

type 'a t = 'a tag

register ~name ~uuid (module T) creates a new variant constructor, that accepts values of type T.t. Module T should implement Binable.S and Sexpable.S interfaces, provide compare and pretty-printing pp functions. This functions will be used to print, compare and serialize values.

uuid and name parameters must be string literals, i.e., they must be known at compile time. This is to prevent the abuse of type system.

The returned value of type T.t tag is a special key that can be used with create and get functions to pack and unpack values of type T.t into value.

val register : name:literal -> uuid:literal -> (module S with type t = 'a) -> 'a tag

register ~name ~uuid (module T) creates a new variant constructor, that accepts values of type T.t. Module T should implement Binable.S and Sexpable.S interfaces, provide compare and pretty-printing pp functions. This functions will be used to print, compare and serialize values.

uuid and name parameters must be string literals, i.e., they must be known at compile time. This is to prevent the abuse of type system.

The returned value of type T.t tag is a special key that can be used with create and get functions to pack and unpack values of type T.t into value.

val name : 'a t -> string

name cons returns a name of a constructor.

val same : 'a t -> 'b t -> bool

same x y is true if tags x and y have the same type.

val same_witness : 'a t -> 'b t -> ('a, 'b) Core_kernel.Std.Type_equal.t option

same_witness x y returns a value witnessing that value tags x and y has the same type.

val same_witness_exn : 'a t -> 'b t -> ('a, 'b) Core_kernel.Std.Type_equal.t

same_witness_exn x y is the same as same_witness but raises exception if not (same x y).

val typeid : 'a t -> typeid

typeid t returns a type identifier of a type tag t.