Closed chris-martin closed 1 year ago
The docs for prefilterM include the following statement:
prefilterM
foldM (prefilterM p folder) list = foldM folder (filter p list)
On the left side, p has type a -> m Bool. On the right side, it has type a -> Bool.
p
a -> m Bool
a -> Bool
The property can be made to type check, but it would no longer be correct:
foldM (prefilterM p folder) list = foldM folder =<< Control.Monad.filterM p list
Because then on the left side, the effects of p are interleaved throughout the folding, whereas on the right side they happen all upfront.
I am not sure what correct property could be salvaged here, other than to restrict the monadic context to Identity:
Identity
foldM (prefilterM (Identity . p) folder) list = foldM folder (filter p list)
I think it's fine to delete the property
The docs for
prefilterM
include the following statement:On the left side,
p
has typea -> m Bool
. On the right side, it has typea -> Bool
.The property can be made to type check, but it would no longer be correct:
Because then on the left side, the effects of
p
are interleaved throughout the folding, whereas on the right side they happen all upfront.I am not sure what correct property could be salvaged here, other than to restrict the monadic context to
Identity
: