SML# Document Version 4.0.0
24 Module language declarations and interface

24.3 Signature expression : sigexp

The syntax of signature expression is given below.

sigexp ::= sig spec end
 | sigid
 | sigexp where type tyvarSeq longTycon = ty
  • Basic signature expression (sig spec end)

    It is a list of declaration specification

  • Signature name (sigid)

    It is a name bound to a signature expression in a top-level signature declaration.

  • Signature name with type definitions

    It represent the signature expression obtained from the signature expression bound to sigin by replacing tyvarSeq longTycon with the specified ty.

The syntax of declaration specification spec is given below.

spec ::= val valdesc
 | type typdesc
 | eqtype  typdesc
 | datatype  datdesc
 | datatype  tycon  =  datatype  longTycon
 | exception  exdesc
 | structure  strdesc
 | include  sigexp
 | spec  sharing type longTycon1  =  = longTyconn
 | spec  (;)?  spec
 |
valdesc ::= vid  :  ty  (and  valdesc)?
typdesc ::= tyvarSeq  tycon  (and  typdesc)?
datdesc ::= tyvarSeq  tycon  =  condesc  (and  datdesc)?
condesc ::= vid  (of  ty)?  (|  condesc)?
exdesc ::= vid  (of  ty)?  (and  exdesc)?
strdesc ::= strid  :  sigexp  (and  strdesc)?

The meaning of each of components is as follows.

  • val valdesc. This specifies the type of each variable bound in a val declaration.

  • type typdesc. This specifies the existence of a type declaration or datatype declaration in a structure expression.

    When the signature is used as a transparent signature constraint, then this specification makes the type function available. If the matching declaration is a datatype declaration, then this specification makes the type constructor available, but data constructors are not bound.

    When the signature is used as an opaque signature constraint, then this specification changes a type function or a datatype definition to an abstract type constructor.

  • eqtype  typdesc

    This is the same as type  typdesc with the additional constraint that the type declared in a structure is restricted to a type that admit equality.

  • datatype  datdesc

    This specifies that a datatype declaration exists, and makes the datatype declaration available.

  • datatype  tycon  =  datatype  longTycon

    It specifies that the type constructor bound to the type constructor name tycon is the same as that bound to the long type constructor name longTycon.

  • exception  exdesc

    This specifies that an exception declaration exists, and makes the exception declaration available.

  • structure  strdesc

    It specifies that the structure contain a structure declaration of the specified signature.

  • include

    It expands to the contents (a list of spec) of the signature expression bound to the signature name.

  • sharing type

    This specifies that the specified set of long type constructor names are bound to the same type constructor.