Separate left and right values in distinct streams. (
separate
is a more powerful, functor-general, equivalent using
Sum in
place of
Either). So, for example, to permit unlimited user
input of
Ints on condition of only two errors, we might
write:
>>> S.toList $ S.print $ S.take 2 $ partitionEithers $ S.map readEither $ S.stdinLn :: IO (Of [Int] ())
1<Enter>
2<Enter>
qqqqqqqqqq<Enter>
"Prelude.read: no parse"
3<Enter>
rrrrrrrrrr<Enter>
"Prelude.read: no parse"
[1,2,3] :> ()
partitionEithers = separate . maps S.eitherToSum
lefts = hoist S.effects . partitionEithers
rights = S.effects . partitionEithers
rights = S.concat