[Git][ghc/ghc][master] Add `Data.Functor.unzip`

Marge Bot (@marge-bot) gitlab at gitlab.haskell.org
Wed Mar 8 02:21:59 UTC 2023



Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC


Commits:
fa559c28 by Ollie Charles at 2023-03-07T20:56:21+00:00
Add `Data.Functor.unzip`

This function is currently present in `Data.List.NonEmpty`, but `Data.Functor`
is a better home for it. This change was discussed and approved by the CLC
at https://github.com/haskell/core-libraries-committee/issues/88.

- - - - -


2 changed files:

- libraries/base/Data/Functor.hs
- libraries/base/changelog.md


Changes:

=====================================
libraries/base/Data/Functor.hs
=====================================
@@ -43,10 +43,12 @@ module Data.Functor
       ($>),
       (<$>),
       (<&>),
+      unzip,
       void,
     ) where
 
 import GHC.Base ( Functor(..), flip )
+import Data.Tuple ( fst, snd )
 
 -- $setup
 -- Allow the use of Prelude in doctests.
@@ -159,6 +161,9 @@ infixl 4 $>
 ($>) :: Functor f => f a -> b -> f b
 ($>) = flip (<$)
 
+unzip :: Functor f => f (a,b) -> (f a, f b)
+unzip xs = (fst <$> xs, snd <$> xs)
+
 -- | @'void' value@ discards or ignores the result of evaluation, such
 -- as the return value of an 'System.IO.IO' action.
 --


=====================================
libraries/base/changelog.md
=====================================
@@ -11,6 +11,7 @@
       ([CLC proposal #113](https://github.com/haskell/core-libraries-committee/issues/113))
   * Add `Type.Reflection.decTypeRep`, `Data.Typeable.decT` and `Data.Typeable.hdecT` equality decisions functions.
       ([CLC proposal #98](https://github.com/haskell/core-libraries-committee/issues/98))
+  * Add `Data.Functor.unzip` ([CLC proposal #88](https://github.com/haskell/core-libraries-committee/issues/88))
 
 ## 4.18.0.0 *TBA*
 



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/fa559c28d22888a4ba497daca2c1d5afdebb716c

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/fa559c28d22888a4ba497daca2c1d5afdebb716c
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20230307/666f0d8c/attachment-0001.html>


More information about the ghc-commits mailing list