package ocaml-base-compiler

  1. Overview
  2. Docs
Official release 5.2.1

Install

Dune Dependency

Authors

Maintainers

Sources

ocaml-5.2.1.tar.gz
sha256=2d0f8090951a97a2c0e5b8a11e90096c0e1791d2e471e4a67f87e3b974044cd0

doc/stdlib/Stdlib/Type/index.html

Module Stdlib.TypeSource

Type introspection.

  • since 5.1

Type equality witness

Sourcetype (_, _) eq =
  1. | Equal : ('a, 'a) eq

The purpose of eq is to represent type equalities that may not otherwise be known by the type checker (e.g. because they may depend on dynamic data).

A value of type (a, b) eq represents the fact that types a and b are equal.

If one has a value eq : (a, b) eq that proves types a and b are equal, one can use it to convert a value of type a to a value of type b by pattern matching on Equal:

  let cast (type a) (type b) (Equal : (a, b) Type.eq) (a : a) : b = a

At runtime, this function simply returns its second argument unchanged.

Type identifiers

Sourcemodule Id : sig ... end

Type identifiers.

OCaml

Innovation. Community. Security.