From 51ad3ba0497d54709fa40736df7f424c23ab48f0 Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Mon, 29 Feb 2016 19:41:05 -0500 Subject: [PATCH] Add runBothWith. --- src/Data/Functor/Both.hs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Data/Functor/Both.hs b/src/Data/Functor/Both.hs index c9584e214..6435e39a8 100644 --- a/src/Data/Functor/Both.hs +++ b/src/Data/Functor/Both.hs @@ -11,6 +11,10 @@ newtype Both a = Both { runBoth :: (a, a) } both :: a -> a -> Both a both = curry Both +-- | Apply a function to `Both` sides of a computation. +runBothWith :: (a -> a -> b) -> Both a -> b +runBothWith f = uncurry f . runBoth + -- | Runs the left side of a `Both`. fst :: Both a -> a fst = Prelude.fst . runBoth