The branches of your case
have different types.
The Left
branch has type Either Effect.Exception.Error a
, because that's how you construct it.
But your Right
branch has the same type as rightRes
, because that's what you're returning from it, and that type is Either Affjax.Error (Response _)
.
So the types don't match.
To make them match, you have to unwrap rightRes
and rewrap it again:
let result = case resultEi of
Left err -> Left $ AX.XHRError err
Right res -> Right res
Yes, it will have the exact same content, but the type will be different.
But if your intent is just to change the type of the error, then I'd recommend lmap
from Bifunctor
:
let result = lmap AX.XHRError resultEi
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…