alice
manual.


Alice Project

the
language


________ Overview ____________________________________________________

Alice ML is based on the Standard ML programming language (SML), as defined in

However, Alice ML features several major extensions relative to SML:

You should also be aware of some


________ Syntax summary ______________________________________________

Reserved words

Alice defines some additional identifiers as reserved words:

	any    constructor   exttype    fct      from       import     non
	lazy   pack          spawn      unpack   withfun    withval

The following grammar collects all syntactic extensions of Alice ML relative to Standard ML. Derived forms are marked (*).

Expressions

atexp ::= ...
#[ exp1 , ... , expn ] vector (n≥0)
{ atexp where exprow } record update
exp ::= ...
lazy exp lazy
spawn exp concurrent
rec pat => exp recursion (*)
pack strexp :> sigexp packing
exprow ::= ...
vid <: ty> <, exprow> label as expression (*)

Patterns

 
atpat ::= ...
#[ pat1 , ... , patn ] vector (n≥0)
( pat1 | ... | patn ) alternative (n≥2)
pat ::= ...
pat as pat layered (R)
non pat negated
pat where atexp guarded (L)

Types

ty ::= ...
_ wildcard

Declarations

dec ::= ... 1)
exttype extbind extensible datatype
constructor econbind generative constructor
fvalbind ::= <lazy | spawn> lazy/concurrent function (m,n≥1) (*)
       <op> vid atpat11 ... atpat1n <: ty1> = exp1
    | <op> vid atpat21 ... atpat2n <: ty2> = exp2
    | ...
    | <op> vid atpatm1 ... atpatmn <: tym> = expm
    <and fvalbind>
extbind ::= tyvarseq tycon extensible datatype
econbind ::= <op> vid <of ty> : tyvarseq longtycon <and econbind> new constructor
<op> vid = <op> longvid <and econbind> synonym
strbind ::= ...
_ <: sigexp> = strexp <and strbind> anonymous structure (*)
funbind ::= strid strpat1 ... strpatn = strexp <and funbind> functor binding (n≥1) (*)

1) The extended phrase class dec contains all of Standard ML's dec, strdec and topdec.

Structures

strexp ::= ...
( strexp ) parentheses
( dec ) structure (*)
strexp strexp functor application 1
unpack infexp : sigexp unpacking
fct strpat => strexp functor
strpat ::= ( strid : sigexp ) parameter
( _ : sigexp ) anonymous parameter (*)
( spec ) signature as parameter (*)

1) See the module syntax summary for a more precise grammar of structure expressions and functor application.

Signatures

sigexp ::= ...
longsigid signature identifier
( sigexp ) parentheses
( spec ) signature (*)
fct strpat -> sigexp functor

Specifications

spec ::= ...
exttype extdesc extensible datatype
constructor econdesc generative constructor
functor fundesc functor specification (*)
signature sigdesc signature specification
extdesc ::= tyvarseq tycon extensible datatype
econdesc ::= <op> vid <of ty> : tyvarseq longtycon <and econdesc> new constructor
fundesc ::= strid strpat1 ... strpatn : sigexp <and fundesc> functor description (n≥1) (*)
sigdesc ::= sigid <= sigexp> <and sigdesc> signature description

Components

component ::= ann <program> component
ann ::= import imp from string import announcement
import string import all (*)
empty
ann <;> ann
imp ::= val valitem
type typitem
datatype datitem
exttype extitem
constructor econitem
exception exitem (*)
structure stritem
functor funitem (*)
signature sigitem
infix <d> vid1 ... vidn (n≥1)
infixr <d> vid1 ... vidn (n≥1)
nonfix vid1 ... vidn (n≥1)
empty
imp <;> imp
valitem ::= <op> vid <and valitem>
<op> vid : ty <and valitem>
typitem ::= tycon <and typitem>
tyvarseq tycon <and typitem>
datitem ::= tycon <and datitem>
tyvarseq tycon = conitem <and datitem>
conitem ::= <op> vid <of ty> <| conitem>
extitem ::= tycon <and extitem>
tyvarseq tycon <and extitem>
econitem ::= <op> vid <and econitem>
exitem ::= <op> vid <and exitem> (*)
<op> vid of ty <and exitem> (*)
stritem ::= strid <and stritem>
strid : sigexp <and stritem>
funitem ::= strid <and funitem> (*)
strid strpat1 ... strpatn : sigexp <and funitem> (n≥1) (*)
sigitem ::= sigid <and sigitem>


last modified 2003/01/23 15:36