mapBoth
Eitherの
Left
と
Right
の両方を変換する
要は
bimap
型
code:haskell
mapBoth :: (a -> c) -> (b -> d) -> Either a b -> Either c d
実装例
code:haskell
mapBoth f g (Left a) = Left (f a)
mapBoth f g (Right b) = Right (g b)