New in Clean 1.2 ---------------------------------------------------------------------------- With the exception of the slight syntax changes for existential types, all changes are extensions or new facilities such that a Clean 1.1 program will usually run without any change in Clean 1.2. ---------------------------------------------------------------------------- Language * Let statements before guards Let statements before guards are a special scope construct that is useful when using threading parameters. They are introduced by a hash mark ('#') and contain node definitions. Identifiers in the left-hand side of these definitions are not visible in the right-hand side. They are visible in the definitions that follow which have nested scopes. Example (use of let statements with nested scopes) readchars :: *File -> ([Char], *File) readchars file # (ok, char, file) = freadc file | not ok = ([], file) # (chars, file) = readchars file = ([char : chars], file) is equivalent to readchars :: *File -> ([Char], *File) readchars file0 | not ok = ([], file1) = ([char : chars], file2) where (ok, char, file1) = freadc file0 (chars, file2) = readchars file1 * Let expressions You can now introduce local functions for any expression with the let construct. Example: doublefibs n = [let a = fib i in (a, a) \\ i <- [0..n]] * Guards Guards can be nested. To avoid ambiguities, the default case can only be omitted for the outermost guard. * Observing references Observing references are now enabled in the compiler (see the Clean Reference Manual (version 1.2), Chapter 9: Defining Uniqueness Types). * Multidimensional arrays You can now use multidimensial arrays in selection patterns and updates. For example the following function double00 doubles the first elements of the first row of an array. double00 a=:{ [0, 0] = element } = { a & [0, 0] = 2 * element } * Arrays You can now use arrays of length 0 with the following denotation: array = {} * Existential types The syntax for existentially qualified variables in algebraic type definitions has been changed. The quantifier now appears on the right-hand side. For example you write :: Object = E.x: { state :: x , get :: x -> Int , set :: x Int -> x } instead of :: Object E.x = { state :: x , get :: x -> Int , set :: x Int -> x } The scope of the existentially quantified variable is the constructor definition in which it is defined. This change also means that the arity of the type constructor has changed, so you no longer have to use the Void type. In fact, Void is not a a predefined type anymore. f :: Object f = {state :: 0, get :: I, set = K} instead of f :: Object Void f = {state :: 0, get :: I, set = K} * Lambda expressions It's no longer necessary to place parentheses around lambda expressions when they are used as arguments. This is especially useful when using monadic style. For example, you can now write get2Lines = getLine `bind` \first -> getLine `bind` \second -> return (first, second) instead of get2Lines = getLine `bind` (\first -> getLine `bind` (\second -> return (first, second))) ---------------------------------------------------------------------------- Compiler * Lifted arguments en result case expressions The Clean compiler uses type and strictness information for lifted arguments and the result of local functions. Note: This improvement was alreadly implemented in version 1.1 but not described in list of changes from version 1.0 to 1.1 * Generated code The generated code has been improved in a number of places, for example in functions that return strict tuples. * Array comprehensions Array comprehensions now return arrays with unique elements. More efficient code is generated for array comprehensions. * Strictness analysis The strictness analyzer derives more strictness for some functions with guarded alternatives. * Warnings The Clean compiler now gives warnings for functions that are not used in a module and are not exported. No code is generated for these functions. The compiler issues a warning when the default instance of an overloaded function is used. * Bug fixes We've fixed various bugs and probably introduced some new ones. If you find any bugs, please report them to clean-bugs@cs.kun.nl. ---------------------------------------------------------------------------- Standard Enviroment * Exports statements Some export statements were added to the standard environment. This results in more efficient code, because specialised versions are used instead of the overloaded version. ---------------------------------------------------------------------------- Example programs * Rewritten IO examples The IO examples have been rewritten to make use of the new features in Clean 1.2.