Traverse with join?

If I have a function

foo :: Foo -> Aff Effects (Either String Bar)

and a value

baz :: Either String Foo

then traversing will give:

qux :: Aff Effects (Either String (Either String Bar))
qux = traverse foo baz

I can do

join <$> qux :: Aff Effects (Either String Bar)

to get to what I want, but I’m curious if there’s a more idiomatic way of handling this type of situation?

I’ve used join <$> traverse foo bar quite a few times before. It seems like there should be a combinator, but I’m not aware of one, and I think it’s fine.

1 Like

I think in this case you could use ExceptT, which is more descriptive, but probably more verbose if it’s a one off.

1 Like