fork download
  1. mapEithers :: (a -> Either b c) -> [a] -> Either b [c]
  2. mapEithers f (x:xs) = case mapEithers f xs of
  3. Left err -> Left err
  4. Right ys -> case f x of
  5. Left err -> Left err
  6. Right y -> Right (y:ys)
  7. mapEithers _ _ = Right []
  8.  
  9. main = print $ (mapEithers Right "foo" :: Either () String)
Success #stdin #stdout 0s 6276KB
stdin
Standard input is empty
stdout
Right "foo"