[Haskell-cafe] Filtering a big list into the IO monad
haskell at list.mightyreason.com
Thu Aug 3 14:03:15 EDT 2006
Gabriel Sztorc wrote:
> I want to filter a list with a predicate that returns a IO value,
> something that filterM is supposed to do. The problem is, filterM
> overflows the stack for really big lists and I couldn't come up with a
> simple replacement for filterM that would work for lists of any size
> (the truth is, I can't come up with anything at all :).
> The question is: how to do it? Any help is appreciated.
What is the predicate computing? Does it have side effects? Does the order of
A dangerous solution is to use unsafeInterleaveIO or unsafePerformIO to change
your predicate to look like a pure function...
More information about the Haskell-Cafe