4 ms·
Functional programming with monads is the right way to implement this.
by kjhughes 5y ago
Functional programming with monads is the right way to implement this.
- marcosdumay 5y agoIt's obviously `IO Bool`, so it's equivalent to directly evaluating in an imperative language and you gain nothing from the monadic interface. I'm sure some impurity "pragmatist" will try to argue you can make a perfectly good version of it as `Bool`. That kind of pragmatism is better ignored because it interferes with compiler optimization and standardization. As an example, you can look at the recent discussion around `==` and `/=`. (And I just noticed some people may seriously argue that, so here comes the /s.)
- perihelions 5y agoThere's an elegant FP solution that involves searching an infinite data structure using only a finite amount of computation -- actually, with precisely zero computation, because the machine isn't on. It's like lazy evaluation, only more lazy.
- h2odragon 5y agoWait. When the machine isn't on, P=NP! So our security systems are (useless | perfect)! I think there might even be other implications...
- MikeTheGreat 5y agoNice job - having shown that P is the same as NP factorial will allow us to solve a lot of really hard problems!
- rezonant 5y agoGolf clap.
- marcosdumay 5y agoHum... Both P and NP are within the set of algorithms you can run when the computer is on. When it's off it's a different set, so it proves that OP=NOP (where O is for "off").
- avl999 5y agoA sideeffect free api to turn on the computer in haskell would be brilliant.
- WJW 5y agoPlease, can we make it `MonadIO m => m Bool` so that this can work with any IO-like monad and/or monad transformer stacks based off IO? It will also make unit testing much easier.