Skip to content

Commit

Permalink
Merge pull request #16 from soapie/master
Browse files Browse the repository at this point in the history
Fix documentation in Data.Either.Combinators
  • Loading branch information
ekmett committed Feb 6, 2014
2 parents e8210c5 + 002814c commit 2c3485f
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions src/Data/Either/Combinators.hs
Expand Up @@ -39,7 +39,7 @@ import Control.Applicative
-- ---------------------------------------------------------------------------
-- Functions over Either

-- |The 'isLeft' function returns 'True' iff its argument is of the form @Left _@.
-- |The 'isLeft' function returns 'True' iff its argument is of the form @'Left' _@.
--
-- Using @Control.Lens@:
--
Expand All @@ -56,7 +56,7 @@ isLeft :: Either a b -> Bool
isLeft (Left _) = True
isLeft _ = False

-- |The 'isRight' function returns 'True' iff its argument is of the form @Right _@.
-- |The 'isRight' function returns 'True' iff its argument is of the form @'Right' _@.
--
-- Using @Control.Lens@:
--
Expand Down Expand Up @@ -89,7 +89,7 @@ fromLeft' (Right _) = error "Data.Either.Combinators.fromLeft: Argument takes fo
fromLeft' (Left x) = x

-- | Extracts the element out of a 'Right' and
-- throws an error if its argument take the form @'Left' _@.
-- throws an error if its argument take the form @'Left' _@.
--
-- Using @Control.Lens@:
--
Expand Down Expand Up @@ -128,7 +128,7 @@ mapBoth f _ (Left x) = Left (f x)
mapBoth _ f (Right x) = Right (f x)

-- | The 'mapLeft' function takes a function and applies it to an Either value
-- iff the value takes the form 'Left _'.
-- iff the value takes the form @'Left' _@.
--
-- Using @Data.Bifunctor@:
--
Expand Down Expand Up @@ -156,13 +156,13 @@ mapBoth _ f (Right x) = Right (f x)
mapLeft :: (a -> c) -> Either a b -> Either c b
mapLeft f = mapBoth f id

-- | The 'mapLeft' function takes a function and applies it to an Either value
-- iff the value takes the form 'Left _'.
-- | The 'mapRight' function takes a function and applies it to an Either value
-- iff the value takes the form @'Right' _@.
--
-- Using @Data.Bifunctor@:
--
-- @
-- 'mapRight' = first
-- 'mapRight' = second
-- @
--
-- Using @Control.Arrow@:
Expand All @@ -174,7 +174,7 @@ mapLeft f = mapBoth f id
-- Using @Control.Lens@:
--
-- @
-- 'mapRight' = 'over' '_Right'
-- 'mapRight' = over _Right
-- @
--
-- >>> mapRight (*2) (Left "hello")
Expand All @@ -186,7 +186,7 @@ mapRight :: (b -> c) -> Either a b -> Either a c
mapRight = mapBoth id

-- | The 'whenLeft' function takes an 'Either' value and a function which returns a monad.
-- The monad is only executed when the given argument takes the form @Left _@, otherwise
-- The monad is only executed when the given argument takes the form @'Left' _@, otherwise
-- it does nothing.
--
-- Using @Control.Lens@:
Expand All @@ -201,8 +201,8 @@ whenLeft :: Applicative m => Either a b -> (a -> m ()) -> m ()
whenLeft (Left x) f = f x
whenLeft _ _ = pure ()

-- | The 'whenLeft' function takes an 'Either' value and a function which returns a monad.
-- The monad is only executed when the given argument takes the form @Right _@, otherwise
-- | The 'whenRight' function takes an 'Either' value and a function which returns a monad.
-- The monad is only executed when the given argument takes the form @'Right' _@, otherwise
-- it does nothing.
--
-- Using @Data.Foldable@:
Expand Down

0 comments on commit 2c3485f

Please sign in to comment.