Curry: An Integrated Functional Logic Language
Curry: An Integrated Functional Logic Language
Curry: An Integrated Functional Logic Language
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
4.1.8 Strings<br />
The type String is an abbreviation for [Char], i.e., strings are considered as lists of characters.<br />
String constants are enclosed in double quotes. Thus, the string constant "Hello" is identical to<br />
the character list [’H’,’e’,’l’,’l’,’o’]. A term can be converted into a string by the function<br />
show :: a -> String<br />
For instance, the result of (show 42) is the character list [’4’,’2’].<br />
4.1.9 Tuples<br />
If t1, t2, . . . , tn are types and n ≥ 2, then (t1,t2,...,tn) denotes the type of all n-tuples. The<br />
elements of type (t1,t2,...,tn) are (x1,x2,...,xn) where xi is an element of type ti (i = 1, . . . , n).<br />
Thus, for each n, the tuple-building operation (,. . .,) (with n − 1 commas) can be considered as<br />
an n-ary constructor introduced by the pseudo-declaration<br />
data (a1,a2, . . . ,an) = (,. . .,) a1 a2...an<br />
where (x1,x2,...,xn) is equivalent to the constructor application “(,. . .,) x1 x2...xn”.<br />
The unit type () has only a single element () and can be considered as defined by<br />
data () = ()<br />
Thus, the unit type can also be interpreted as the type of 0-tuples.<br />
4.2 Type System<br />
<strong>Curry</strong> is a strongly typed language with a Hindley/Milner-like polymorphic type system [13]. 8 Each<br />
variable, constructor and operation has a unique type, where only the types of constructors have<br />
to be declared by datatype declarations (see Section 2.1). The types of functions can be declared<br />
(see Section 2.3) but can also be omitted. In the latter case they will be reconstructed by a type<br />
inference mechanism.<br />
Note that <strong>Curry</strong> is an explicitly typed language, i.e., each function has a type. The type can only<br />
be omitted if the type inferencer is able to reconstruct it and to insert the missing type declaration.<br />
In particular, the type inferencer can reconstruct only those types which are visible in the module<br />
(cf. Section 6). Each type inferencer of a <strong>Curry</strong> implementation must be able to insert the types of<br />
the parameters and the free variables (cf. Section 2.5) for each rule. The automatic inference of the<br />
types of the defined functions might require further restrictions depending on the type inference<br />
method. Therefore, the following definition of a well-typed <strong>Curry</strong> program assumes that the types<br />
of all defined functions are given (either by the programmer or by the type inferencer). A <strong>Curry</strong><br />
implementation must accept a well-typed program if all types are explicitly provided but should<br />
also support the inference of function types according to [13].<br />
A type expression is either a type variable, a basic type like Bool, Success, Int, Float, Char<br />
(or any other type constructor of arity 0), or a type constructor application of the form (T τ1 . . . τn)<br />
8 The extension of the type system to Haskell’s type classes is not included in the kernel language but may be<br />
considered in a future version.<br />
18