Curry: An Integrated Functional Logic Language
Curry: An Integrated Functional Logic Language
Curry: An Integrated Functional Logic Language
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
C Syntax of <strong>Curry</strong><br />
The syntax is still preliminary and not intended to be used by automatic tools. Nevertheless, it<br />
provides a precise definition of the concrete syntax which can be further discussed.<br />
The syntax is close to Haskell but the following differences should be noted.<br />
• As-patterns are missing<br />
• Case expressions are missing<br />
• Currently, there are no infix constructors except for “:”, the predefined list constructor. They<br />
will be added later, although they are already used in concrete example programs.<br />
C.1 Lexicon<br />
The case of identifiers matters, i.e., “abc” differs from “Abc”. There are four case modes selectable<br />
at compilation time:<br />
• Prolog mode: variables start with an upper case latter, all other identifier symbols start with<br />
a lower case letter.<br />
• Gödel mode: like Prolog mode with the cases swapped.<br />
• Haskell mode: see section 1.3 of the Haskell report.<br />
• free: no constraints on the case of identifiers.<br />
The default case mode is free. If a case mode is selected but not obeyed, the compiler issues a<br />
warning.<br />
The syntax does not define the following non-terminal symbols defining classes of identifiers:<br />
ModuleID, TypeConstrID, DataConstrID, TypeVarID, InfixOpID, FunctionID, VariableID. All, except<br />
InfixOpID, consist of an initial letter, whose upper or lower case depend on the case mode,<br />
followed by any number of letters, digits, underscores, and single quotes. Additionally, ModuleID<br />
can contain dots at inner positions. InfixOpID is any string of characters from the string<br />
“~!@#$%^&*+-=?./|\:” or another identifier (like VariableID) enclosed in ‘. . .‘ like ‘mod‘.<br />
The following symbols are keywords and cannot be used as an identifier:<br />
as case choice data do else external<br />
free hiding if import in infix infixl<br />
infixr let module of qualified rigid then<br />
type where<br />
The syntax leaves undefined Literal of primitive types. These are literal constants, such as “1”,<br />
“3.14”, or the character “’a’”. They are as in Java. Java, in constrast to Haskell, adopts the<br />
Unicode standard to represent characters and character strings.<br />
Comments begins either with “--” and terminate at the end of the line or with “{-” and<br />
terminate with a matching “-}”, i.e., the delimiters “{-” and “-}” act as parentheses and can be<br />
nested.<br />
59