Monuses and Heaps
9 points by lalitm
9 points by lalitm
Maybe I'm a bit too thick for this post, but coming from mostly using imperative languages nowadays, I'm struggling to come up with concrete practical examples where the articulated abstraction is useful over the "stupid" thing you would do.
E.g. for general graph search, I'd reach for Dijkstra or A*. I don't think you can get away with storing relative distances there due to the presence of multiple paths.
For the Phases example, if you have ordering constraints, you probably have dynamic dependencies between things so you have a Monad, not just an Applicative. When you have a shared resource used by individual computations one different branches, they cannot happen "completely independently."
Consider you have a build DAG and you want to do a critical path search. If the actions themselves are nodes, then the naive thing would be to store the time for each action at the corresponding node (not the total time from the start).
Re: the Search type, I've used that kind of lazy tree representation before and it's all fine and dandy until the memory usage blows up in your face because there's no explicit tracking for "how much of the state space I'm holding" at any given time.
It's quite possible I'm missing something -- I would love if someone could share a concrete example of a problem they've hit where they think having the formulation in the article would've been genuinely useful.
Not really touching on the heaps part of the article, but, out of necessity, I've invented a poorly implemented, half baked version of monuses multiple times when dealing with undo.
I always get there via the same, three-step process: