Say I have two functions:
b2c :: B -> Either String C
a2bs :: A -> [[B]]
How to make the following a2cs function using b2c and a2bs such that if there is any Left value in the [[Either String c]] then Either String [[c]] should be a Left value?
a2cs :: A -> Either String [[C]]
I would write this:
a2cs = traverse (traverse b2c) . a2bs
Although this doesn't use exactly your proposed implementation strategy of first producing a [[Either String C]] and then flattening that to Either String [[C]], it has the advantage that it requires only one pass over the nested lists rather than the two required by your strategy.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With