package containers

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

Create a new bitfield type

Parameters

module X : EMPTY

Signature

type t = private int

Generative type of bitfields. Each instantiation of the functor should create a new, incompatible type

val empty : t

Empty bitfields (all bits 0)

type _ field_kind =
  1. | Bool : bool field_kind
  2. | Int : int field_kind
module type FIELD = sig ... end

Field of type value, with a given width and position within the bitfield type

type 'a field = (module FIELD with type value = 'a)
val bool : ?name:string -> unit -> bool field

New field of type bool

  • raises Frozen

    if freeze () was called

val int2 : ?name:string -> unit -> int field

New field of type 2-bits int (same as int ~width:2)

  • raises Frozen

    if freeze () was called

val int3 : ?name:string -> unit -> int field

New field of type 3-bits int (same as int ~width:3)

  • raises Frozen

    if freeze () was called

val int : ?name:string -> width:int -> unit -> int field

New field for width bits.

  • raises Frozen

    if freeze () was called

  • raises Invalid_argument

    if width is not <= 1

val freeze : unit -> unit

Prevent new fields from being added. From now on, creating a field will raise Frozen

val total_width : unit -> int

Current width of the bitfield

type any_field =
  1. | AnyField : (module FIELD with type value = 'a) * 'a field_kind -> any_field
val iter_fields : (any_field -> unit) -> unit

Iterate on all currently present fields

val pp : Format.formatter -> t -> unit

Print the bitfield using the current list of fields

OCaml

Innovation. Community. Security.