Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

They lost me at the point, after demonstrating how a functor can be defined on a list, when they claimed that a functor can similarly be defined on a binary tree.

One of the ten or so "Aha!" moments that each Haskell novice must experience on one's journey to mastery is the realization that you can't make Set an instance of Functor, at least as Functor is commonly defined in the standard Prelude. And the reason why one cannot do so is echoed by their misleading diagram in which their functor replaces each node in a binary tree with its mapped value. What needs to be appreciated is that the resulting tree is no longer ordered (assuming that the original was), and cannot be used to locate an element in logarithmic time.



They didn't say it was a binary search tree. The term Tree can simply be a root value and subtrees of children with a parent node, represented as a set of linked nodes.


That's fair, and one might usefully structure data thus if coding in a Lisp.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: