3 ms·
This part could be more simply explained: > The problem is that a "do" block in the list monad chains together several of these flatMap calls. It is very easy
by skybrian 5y ago
This part could be more simply explained:
> The problem is that a "do" block in the list monad chains together several of these flatMap calls. It is very easy for the transformation function to result in the computation growing exponentially as each one expands one item from before into one or more items. You have to have something else in the problem that prevents that from happening. You may see a lot of cute little algorithms like solving the n-queens problem, but in practice, this is not something you see used a lot in Haskell. The mathematical transform is cute, but hard to control because it's a bit too simple. In particular, this has no ability to "notice" that it is revisiting possibilities it visited before. That would take more machinery.
I think he's saying that it's doing a depth-first search without any caching. I'm wondering if Haskell has some other nice way of specifying depth-first searches that performs better?
- themk 5y agoQuite often what you want is LogicT which gives you more control and can significantly improve performance over List.