Clean is a general-purpose purely functional computer programming language. It was called the Concurrent Clean System, then the Clean System, later just Clean. Clean has been developed by a group of researchers from the Radboud University in Nijmegen since 1987.
The language Clean first appeared in 1987. Although development of the language has slowed, some researchers are still working in the language. In 2018, a spin-off company was founded that uses Clean.
Clean shares many properties and syntax with a younger sibling language, Haskell: referential transparency, list comprehension, guards, garbage collection, higher order functions, currying, and lazy evaluation. However, Clean deals with mutable state and input/output (I/O) through a uniqueness type system, in contrast to Haskell's use of monads. The compiler takes advantage of the uniqueness type system to generate more efficient code, because it knows that at any point during the execution of the program, only one reference can exist to a value with a unique type. Therefore, a unique value can be changed in place.
An integrated development environment (IDE) for Microsoft Windows is included in the Clean distribution.
Hello world:
Start = "Hello, world!"
Factorial:
Fibonacci sequence:
Infix operator:
(^) infixr 8 :: Int Int -> Int
(^) x 0 = 1
(^) x n = x * x ^ (n-1)
The type declaration states that the function is a right associative infix operator with priority 8: this states that xx^(n-1) is equivalent to x(x^(n-1)) as opposed to (x*x)^(n-1). This operator is pre-defined in StdEnv, the Clean standard library.
Computing is based on graph rewriting and reduction. Constants such as numbers are graphs and functions are graph rewriting formulas. This, combined with compiling to native code, makes Clean programs which use high abstraction run relatively fast according to The Computer Language Benchmarks Game.
Compilation of Clean to machine code is performed as follows:
Source files (.icl) and definition files (.