{- Copyright (c) 2011 Robert Henderson This source file is distributed under the terms of a BSD3-style license, which can be found in the file LICENSE at the root of this package. -} -- | Extends "Data.Either" -- module Data.Either.Rosso1 (module Data.Either ,mapLeft ,mapRight ) where ------------------------------------------------------ import Data.Either -- | Applies a function to the left component. -- mapLeft :: (a -> c) -> Either a b -> Either c b mapLeft f (Left x) = Left (f x) mapLeft _ (Right x) = Right x -- | Applies a function to the right component. -- mapRight :: (b -> c) -> Either a b -> Either a c mapRight _ (Left x) = Left x mapRight f (Right x) = Right (f x) ----------------------------------------------------------- {- UNIT TESTS *Rosso.Either1e> mapLeft (+ 10) (Left 4) Left 14 *Rosso.Either1e> mapLeft (+ 10) (Right 4) Right 4 *Rosso.Either1e> mapRight (+ 10) (Left 4) Left 4 *Rosso.Either1e> mapRight (+ 10) (Right 4) Right 14 -}