signature PACKAGE structure Package : PACKAGE
The Package structure provides functionality to construct and destruct packages. A package is a value encapsulating an arbitrary (higher-order) module and its signature. Packages enrich the static type system of ML with a dimension of dynamic typing: unpacking a package performs a dynamic type check. That basic mechanism is used to make safe all kinds of dynamic operations, particularly exchange of higher-order data structures between different processes (see structure Remote), or export to a file system (pickling).
The type package is available in the top-level environment.
See also: Pickle, Component, Compiler, Remote
signature PACKAGE = sig type package type t = package type mismatch = Inf.mismatch exception Mismatch of mismatch functor Pack (signature S structure X : S) : (val package : package) functor Unpack (val package : package signature S) : S functor PackVal (type t val x : t) : (val package : package) functor UnpackVal (val package : package type t) : (val x : t) end
The type of packages. A package contains an arbitrary module and its signature.
A type containing the abstract description of the reason of a signature match failure.
Raised upon failed attempts to unpack a package.
Creates a package encapsulating the module X under signature S. Returns a structure containing the package value as its only field. Equivalent to
(val package = pack X : S)
Tries to unpack the package package. If the signature of the package matches S, the encapsulated module is returned. Otherwise, the exception Mismatch mismatch will be raised, with mismatch describing the reason for the failure. Equivalent to
unpack package : S
Creates a value package with signature (val x : t), encapsulating the value v under type t. Returns a structure containing the package value as its only field.
Tries to unpack the value package package. If the type of the package is t, returns a structure containing the encapsulated value as its only field. Otherwise, the exception Mismatch will be raised.