4 ms·
The article talks about creating a tree with a unique tag for each node. IMHO, their proposed solution (using a monad) makes the tree creation code simpler by r
by cmiles74 11y ago
The article talks about creating a tree with a unique tag for each node. IMHO, their proposed solution (using a monad) makes the tree creation code simpler by removing the need to thread the counter through the functions that create the nodes. The code they end up with is conise and readable.
- _delirium 11y agoTo me even more concise and readable is the imperative solution the article also mentions: just refer to a "global" counter and increment it (it doesn't have to actually be global, for that matter, just scoped around the tree-building code). The article doesn't even really argue against that solution. Instead the goal here seems to be more of an intellectual challenge problem: find a functional solution that, unlike the straightforward functional solution (thread state through every function call), is not that much clunkier than the imperative solution.