Timber Keyword: Has …

Feb 07
2011

Keyword: has strict semantics, not lazy as Haskell. This has a major impact on the programming styles of the two languages. Qld Timber has Haskell-like type classes, but with slightly different syntax for both type class and instance declarations. The reserved word starting a type class declaration is typeclass . The main reason for this change is that the word class in Qld Timber is used to denote the well-known concept from object-oriented programming. Instances of such types are named values of the type, tagged by instance . The following excerpt from the Prelude illustrates the concept. typeclass Eq a where (==),(/=) :: a -> a -> Bool instance eqUnit :: Eq () eqUnit = struct _ == _ = True _ /= _ = False One cannot attach a deriving -clause to a data type definition. Instead, one can separately request default instances of some type classes. In addition to data types, Qld Timber has a dual notion of struct types. For both data and struct types there is a notion of subtyping with inclusion polymorphism. Qualified types have another syntax in Qld Timber. To illustrate, here is the definition of the function elem from the Prelude: elem :: a -> [a] -> Bool \\ Eq a elem x [] = False elem x (y : ys) = x == y || elem x ys Note: A call to elem will evaluate both arguments completely (because the language is strict), but will not traverse its second argument further when an equality becomes True (because the disjunction “operator” || is non-strict in its right operand). In Qld Timber one can express monadic computations using do -notation, but this is reserved for a particular primitive monad Cmd s of commands operating on a state s . It is possible to define the concept of a general monad as in Haskell (it is in fact defined in the prelude), but the do -notation is not available for general monads. The Cmd monad provides powerful constructs for object-oriented programming, with objects encapsulating a local state and methods manipulating this state. This is achieved while retaining the pure nature of the language; a computation with side-effects is clearly indicated by a monadic type (and can hence not be used in a non-monadic context). Further, methods execute concurrently, but with exclusive access to the state of the object; thus Qld Timber is also a concurrent language with some real-time constructs. The main program of a Qld Timber program is not of type IO () (this type does not exist in Qld Timber), but there must be a designated root module with a root definition; the type of this depends on the target environment. In the present distribution, only a rudimentary is provided. The type system of Qld Timber implements many of the non-standard features that are implemented as extensions in GHC. See more details on the page that discusses .