Quote
Haskell's overlooked object system
Major new release, September 10, 2005
Authors
Oleg Kiselyov and Ralf Lämmel
Abstract
Haskell provides type-class-bounded and parametric polymorphism as opposed to subtype polymorphism of object-oriented languages such as Java and OCaml. It is a contentious question whether Haskell~98 without extensions, or with common extensions, or with new extensions can fully support conventional object-oriented programming with encapsulation, mutable state, inheritance, overriding, statically checked implicit and explicit subtyping, and so on.
In a first phase, we demonstrate how far we can get with object-oriented functional programming, if we restrict ourselves to plain Haskell~98. In the second and major phase, we systematically substantiate that Haskell~98, with some common extensions, supports all the conventional OO features plus more advanced ones, including first-class lexically scoped classes, implicitly polymorphic classes, flexible multiple inheritance, safe downcasts and safe co-variant arguments. Haskell indeed can support width and depth, structural and nominal subtyping. We address the particular challenge to preserve Haskell's type inference even for objects and object-operating functions. Advanced type inference is a strength of Haskell that is worth preserving. Many of the features we get ``for free'': the type system of Haskell turns out to be a great help and a guide rather than a hindrance.
The OO features are introduced in Haskell as the OOHaskell library, non-trivially based on the HList library of extensible polymorphic records with first-class labels and subtyping. The library sample code, which is patterned after the examples found in OO textbooks and programming language tutorials, including the OCaml object tutorial, demonstrates that OO code translates into OOHaskell in an intuition-preserving way: essentially expression-by-expression, without requiring global transformations.
OOHaskell lends itself as a sandbox for typed OO language design.
Major new release, September 10, 2005
Authors
Oleg Kiselyov and Ralf Lämmel
Abstract
Haskell provides type-class-bounded and parametric polymorphism as opposed to subtype polymorphism of object-oriented languages such as Java and OCaml. It is a contentious question whether Haskell~98 without extensions, or with common extensions, or with new extensions can fully support conventional object-oriented programming with encapsulation, mutable state, inheritance, overriding, statically checked implicit and explicit subtyping, and so on.
In a first phase, we demonstrate how far we can get with object-oriented functional programming, if we restrict ourselves to plain Haskell~98. In the second and major phase, we systematically substantiate that Haskell~98, with some common extensions, supports all the conventional OO features plus more advanced ones, including first-class lexically scoped classes, implicitly polymorphic classes, flexible multiple inheritance, safe downcasts and safe co-variant arguments. Haskell indeed can support width and depth, structural and nominal subtyping. We address the particular challenge to preserve Haskell's type inference even for objects and object-operating functions. Advanced type inference is a strength of Haskell that is worth preserving. Many of the features we get ``for free'': the type system of Haskell turns out to be a great help and a guide rather than a hindrance.
The OO features are introduced in Haskell as the OOHaskell library, non-trivially based on the HList library of extensible polymorphic records with first-class labels and subtyping. The library sample code, which is patterned after the examples found in OO textbooks and programming language tutorials, including the OCaml object tutorial, demonstrates that OO code translates into OOHaskell in an intuition-preserving way: essentially expression-by-expression, without requiring global transformations.
OOHaskell lends itself as a sandbox for typed OO language design.
http://homepages.cwi...skell/paper.pdf

New Topic/Question
Reply



MultiQuote





|