diff options
| author | Edvard Hübinette <edvard@hubinette.me> | 2017-04-04 21:48:37 -0400 |
|---|---|---|
| committer | Ben Gamari <ben@smart-cactus.org> | 2017-04-04 21:48:39 -0400 |
| commit | 486b8db05fefd1cfa916928c74958f8099b9f9f8 (patch) | |
| tree | 3ed482cc6465c261e46c59d6ffbe6a5251edb6ba | |
| parent | 1831aed16d9883b2845fa6997e38b9ac3d72f191 (diff) | |
| download | haskell-486b8db05fefd1cfa916928c74958f8099b9f9f8.tar.gz | |
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
| -rw-r--r-- | libraries/base/Control/Applicative.hs | 7 | ||||
| -rw-r--r-- | libraries/base/changelog.md | 5 |
2 files changed, 11 insertions, 1 deletions
diff --git a/libraries/base/Control/Applicative.hs b/libraries/base/Control/Applicative.hs index 9045bcd742..559cceda66 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 f2ea265a0d..854a9b81ed 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* |
