|
![](/i/fill.gif) |
>> More succinctly: In OO, trees are usually mutable. In Haskell, trees
>> are usually immutable.
>
> Not that so much as identity is an important aspect of OO, where it
> isn't in functional programming. Two different objects with exactly the
> same value are nevertheless not interchangable.
The OO definition of "object": "An object has identity, state and
behaviour."
Of course, objects have identity *because* they're mutable. For
immutable objects, identity is irrelevant. (Even in an OO system it's
unimportant, regardless of whether you can measure it or not.)
Since most Haskell things are immutable, identity isn't much of an issue.
(The other thing, of course, is the whole "behaviour" part. Objects
aren't passive data structures, but active mini-programs. This makes
identity kinda important!)
>> A bigger part of it is that, while essentially Haskell has pointers,
>> null pointers are explicitly prohibited.
>
> You could always have Branch hold a couple of Maybe Leaf's.
Sure. But it's simpler (and probably more performant) to just define
multiple node types. ;-)
--
http://blog.orphi.me.uk/
http://www.zazzle.com/MathematicalOrchid*
Post a reply to this message
|
![](/i/fill.gif) |