From acca5d89177125967ab19fc33dcc9f423f0e13ce Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Mon, 29 Feb 2016 09:33:38 -0500 Subject: [PATCH] Add runLeft/runRight conveniences. --- src/Data/Functor/Both.hs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/Data/Functor/Both.hs b/src/Data/Functor/Both.hs index 4593dfcae..a71eb2d13 100644 --- a/src/Data/Functor/Both.hs +++ b/src/Data/Functor/Both.hs @@ -10,6 +10,14 @@ newtype Both a = Both { runBoth :: (a, a) } both :: a -> a -> Both a both = curry Both +-- | Runs the left side of a `Both`. +runLeft :: Both a -> a +runLeft = fst . runBoth + +-- | Runs the right side of a `Both`. +runRight :: Both a -> a +runRight = snd . runBoth + zip :: Both [a] -> [Both a] zip = zipWith both