[Haskell-cafe] Encapsulation in Haskell

Jared Updike jupdike at gmail.com
Thu Dec 22 15:58:52 EST 2005


> > So one of the big things in object oriented programming is
> > encapsulation, and I'm wondering how to do it properly in
> > Haskell.  How do you define new data types but minimize the
> > dependence of external packages on the exact nature of the
> > data definition?
> Use modules. Don't expose the constructors.

Instead, just expose functions that implement the functionality users
of your library will need:

http://www.haskell.org/hawiki/AbstractDataType
http://www.haskell.org/hawiki/AbstractDataTypes

  Jared.

--
jupdike at gmail.com
http://www.updike.org/~jared/
reverse ")-:"


More information about the Haskell-Cafe mailing list