- Type and Pattern identifiers: words formed by of unicode letters and and the underscore "_" character, starting by a capitalized letter.
- value identifiers: words formed by of unicode letters and the underscore " _" character, starting by a capitalized letter or underscore.
- Large integers:
- Values:
0,1,2,3,... - Types: intervals
-*--10, 20--30, 50--*, ... , singletons0,1,2,3,... - Operators:
+,-,/,*,div,mod, int_of
- Values:
- Unicode characters:
- Values:
'a','b','c'... - Types: intervals
'a'--'z', '0'--'9' , singletons'a','b','c',...
- Values:
- Symbolic atoms:
- Values:
`A, `B, `a, `b, `true, `false, ... - Types: singletons
`A, `B, ... - Operators:
atom_of : String -> Atom
- Values:
- Infix:
@ : String,String -> String
+,*,-,div,mod : Integer,Integer -> Integer
=, <<, <=, >>, >= : Integer,Integer -> Bool =`true | `false - Prefix:
load_xml,load_html : String -> Any,dump_to_file : String -> String -> Any,print_xml : Any -> Stringprint : String -> []int_of : [('0'--'9')+] -> Integerstring_of : Integer -> String - Postfix:
?,*,+,??,*?,+? : for regexp
- Expressions:
(e1,e2) - Types and patterns:
(t1,t2) - Note: tuples are right-associative pairs; e.g.:
(1,2,3)=(1,(2,3)) - When a capture variable appears on both side of a pair pattern,
the two captured values are paired
together (e.g.
match (1,2,3) with (x,(_,x)) -> x ==> (1,3) ).
- Expressions:
[ 1 2 3 ] , which is syntactic sugar for(1,(2,(3,`nil))) - A sub-sequence can be escaped by !:
[ 1 2 ![ 3 4 ] 5 ] is then equal to[ 1 2 3 4 5 ] . - Types and patterns :
[ R ] whereR is a regular expression built on types and patterns:- A type or a pattern is a regexp by itself, matching a single element of the sequence
- Postfix repetition operators:
*,+,? and the ungreedy variants (for patterns)*?, +? ,?? - Concatenation of regexps
- For patterns, sequence capture variable
x::R
- It is possible to specify a tail, for expressions, types, and patterns;
e.g.:
[ x::Int*; q ] - Map:
map e with p1 -> e1 | ... | pn -> en . Each element of e must be matched. - Transform:
transform e with p1 -> e1 | ... | pn -> en . Unmatched elements are discarded; each branch returns a sequence and all the resulting sequences are concatenated together. - Operators: concatenation
e1 @ e2 = [ !e1 !e2 ] , flatteningflatten e = transform e with x -> x .
- Records litteral
{ l1 = e1; ...; ln = en } - Types:
{| l1 = t1; ...; ln = tn |} (closed, no more fields allowed),>{ l1 = t1; ...; ln = tn } (open, any other field allowed). Optional fields:li =? ti instead ofli = ti . - Record concatenation:
e1 + e2 (priority to the fields from the right argument) - Field removal:
e1 \ l (does nothing if the fieldl is not present) - Field access:
e1 . l - Record:
{ l1 = p1; ...; ln = pn }
- Strings are actually sequences of characters.
- Expressions:
"abc", [ 'abc' ], [ 'a' 'b' 'c' ] . - Operators:
string_of, print, dump_to_file PCDATA meansChar* inside regular expressions
- Expressions:
<(tag) (attr)>content - If the tag is an atom
`X , it can be writtenX (without the(..) ). Similarly, parenthesis and curly braces may be omitted when attr is a recordl1=e1;...;ln=en . E.g:<a href="abc">[ 'abc' ] . - Types and patterns: same notations.
- Operators:
load_xml : String -> Any; print_xml : Any -> String
- Expressions:
- General form:
fun f (t1->s1;...;tn->sn) p1 -> e1 | ... | pn -> en (f is optional) - Simple function:
fun f (p : t) : s = e , equivalent tofun f (t -> s) p -> e - Multiple arguments:
fun f (p1 : t1, p2 : t2,...) : s = e , equivalent tofun f ((p1,p2,...):(t1,t2,...)) : s = e
- General form:
- Types:
t -> s
- Type restriction:
(e : t) (forgets any more precise type fore ) - Pattern matching:
match e with p1 -> e1 | ... | pn -> en - Local binding:
let p = e1 in e2 , equivalent tomatch e1 with p -> e2 ;let p : t = e1 in e2 equivalent tolet p = (e1 : t) in e2 - If-then-else:
if e1 then e2 else e3 , equivalent tomatch e1 with `true -> e2 | `false -> e3 - Exceptions:
- Raise exception:
raise e - Handle exception:
try e with p1 -> e1 | ... | pn -> en
- Raise exception:
- Boolean connectives:
&,|,\ (| is first-match). - Empty and universal types:
Empty,Any or_ . - Recursive types and patterns:
t where T1 = t2 and ... and Tn = tn . - Capture variable:
x . - Default values:
(x := c) .
- Type declarations:
type T = t . - Source inclusion:
include filename_string - Debug directives:
debug directive argument
where directive is one of the following:accept ,subtype ,compile .
This page has been generated by a CDuce program.