[commit: ghc] master: Add Alternative instance for ZipList (fix #13520). (486b8db)
git at git.haskell.org
git at git.haskell.org
Wed Apr 5 02:23:19 UTC 2017
Repository : ssh://git@git.haskell.org/ghc
On branch : master
Link : http://ghc.haskell.org/trac/ghc/changeset/486b8db05fefd1cfa916928c74958f8099b9f9f8/ghc
>---------------------------------------------------------------
commit 486b8db05fefd1cfa916928c74958f8099b9f9f8
Author: Edvard Hübinette <edvard at hubinette.me>
Date: Tue Apr 4 21:48:37 2017 -0400
Add Alternative instance for ZipList (fix #13520).
Reviewers: austin, hvr, bgamari, RyanGlScott
Reviewed By: RyanGlScott
Subscribers: adamse, RyanGlScott, rwbarton, thomie
Differential Revision: https://phabricator.haskell.org/D3416
>---------------------------------------------------------------
486b8db05fefd1cfa916928c74958f8099b9f9f8
libraries/base/Control/Applicative.hs | 7 ++++++-
libraries/base/changelog.md | 5 +++++
2 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/libraries/base/Control/Applicative.hs b/libraries/base/Control/Applicative.hs
index 9045bcd..559cced 100644
--- a/libraries/base/Control/Applicative.hs
+++ b/libraries/base/Control/Applicative.hs
@@ -59,7 +59,7 @@ import Data.Functor.Const (Const(..))
import GHC.Base
import GHC.Generics
-import GHC.List (repeat, zipWith)
+import GHC.List (repeat, zipWith, drop)
import GHC.Read (Read)
import GHC.Show (Show)
@@ -121,6 +121,11 @@ instance Applicative ZipList where
pure x = ZipList (repeat x)
liftA2 f (ZipList xs) (ZipList ys) = ZipList (zipWith f xs ys)
+-- | @since 4.11.0.0
+instance Alternative ZipList where
+ empty = ZipList []
+ ZipList xs <|> ZipList ys = ZipList (xs ++ drop (length xs) ys)
+
-- extra functions
-- | One or none.
diff --git a/libraries/base/changelog.md b/libraries/base/changelog.md
index f2ea265..854a9b8 100644
--- a/libraries/base/changelog.md
+++ b/libraries/base/changelog.md
@@ -1,5 +1,10 @@
# Changelog for [`base` package](http://hackage.haskell.org/package/base)
+## 4.11.0.0 *TBA*
+ * Bundled with GHC *TBA*
+
+ * Add `Alternative` instance for `ZipList` (#13520)
+
## 4.10.0.0 *April 2017*
* Bundled with GHC *TBA*
More information about the ghc-commits
mailing list