Module Ocaml_typing.Scalar

This module defines: The scalar types intrinsic to the OCaml compiler, and all of the primitive operations defined on them.

Overview: This module provides a comprehensive type system for scalar values in OCaml.

Type Hierarchy:

Representation Forms:

Operations:

The locality parameter tracks where boxed values are allocated.

A Scalar.t represents a particular OCaml type that represents a scalar value. It might be tagged, boxed, or neither. There is also a type parameter for the locality of the scalar value, which represents the location in which that boxed values are allocated.

The important consideration is for a Scalar.t to represent all of the argument and return types of all the primitives that we want to support. The submodules are organized to make it easy for use different subsets of scalars in different places. Some examples:

In some cases, only the number of bits used in the container (e.g. a machine register or stack slot) is important. We use Width for this. Width.t always represents the width of a scalar layout -- it has exactly one constuctor for each bit-width of the corresponding scalar. The type parameter is irrelevant within the Width module, that's why it's usually fixed to any_locality_mode when the corresponding function is expecting a simple sum type (e.g., to_string).

type any_locality_mode =
  1. | Any_locality_mode
val equal_any_locality_mode : any_locality_mode -> any_locality_mode -> bool
module Maybe_naked : sig ... end
val naked : 'a -> (_, 'a) Maybe_naked.t
module type S := sig ... end
module Integral : sig ... end
module Floating : sig ... end
module Width : sig ... end
include S with type 'a width := 'a Width.t
val all : any_locality_mode t list
val map : 'a t -> f:('a -> 'b) -> 'b t
val ignore_locality : _ t -> any_locality_mode t
val width : _ t -> any_locality_mode Width.t
val to_string : any_locality_mode t -> string
val equal : ('a -> 'b -> bool) -> 'a t -> 'b t -> bool
val integral : 'a Integral.t -> 'a t
val floating : 'a Floating.t -> 'a t
module Signedness : sig ... end
module Integer_comparison : sig ... end
module Float_comparison : sig ... end
type 'a scalar := 'a t
module Operation : sig ... end