--- Philippa Cowderoy <[EMAIL PROTECTED]> wrote: > On Thu, 22 Dec 2005, Creighton Hogg wrote: > > > Hi guys, > > 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. >
The trick, though, is that objects are stateful things. If you want to program a binary search tree, then insertion ought to return an entirely new tree, just as if objects were all immutable, and operations on those objects simply creaqte new objects exactly like the existing ones (except for the one change). I've thought about trying to model this using monads and actions, but I'm not sure that's the best approach. === Gregory Woodhouse <[EMAIL PROTECTED]> "Interaction is the mind-body problem of computing." --Philip L. Wadler _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe