[Haskell-cafe] State of OOP in Haskell

Donald Bruce Stewart dons at cse.unsw.edu.au
Sat Jan 27 22:14:39 EST 2007


deliverable:
> Well, I'm thinking in terms of OOD/OOA/OOP -- Design, Architecture,
> Programming.  That's about the only way to model a bog system.  Say I
> have a stock market model -- I'll have a database of tickers, a
> simulator to backtest things, a trading strategy, etc.
> 
> Do Haskell modules provide enough encapsulation to design a system in
> terms of them?  What are the design/architecture units in Haskell if
> not OO-based?

Haskell's pretty big on encapsulation (we like our strong statically
checked guarantees after all)

Some of the encapsulation mechanisms used in large (>5k loc up to 100k +
Haskell programs I've hacked on):

    modules
    qualified modules
    type classes to specify generic interfaces
    existential types to hide implementations completely (and statically)
    existentials using typeclasses to package the interface
    monads for state/effect encapsulation
    abstract data types
    data types with smart constructors
    first class modules via existentials 
    purity 
    laziness

So the same kind of encapsulation as OO stuff provides (existentials are
essentially OO objects), and a few more besides. Monads in particular
are perfect for encapsulating interesting effects, and having that
encapsulation statically enforced.

Probably some of the OO refugees can think of other mechanisms.

Cheers,
   Don


More information about the Haskell-Cafe mailing list