Add Bifoldable and Bitraversable to base
authorRyan Scott <ryan.gl.scott@gmail.com>
Sat, 18 Jun 2016 10:17:24 +0000 (12:17 +0200)
committerBen Gamari <ben@smart-cactus.org>
Sat, 18 Jun 2016 22:27:06 +0000 (00:27 +0200)
commit270d545d557352d5f264247987ee8388f0812187
tree9ee170579a483695d8ab30c0ea7ac40ad59a4be1
parent6354991fe61b065d2c993eefdd5fd694bc6136b8
Add Bifoldable and Bitraversable to base

This adds `Data.Bifoldable` and `Data.Bitraversable` from the
`bifunctors` package to `base`, completing the migration started in
D336.  This is fairly straightforward, although there were a suprising
amount of reinternal organization in `base` that was needed for this to
happen:

* `Data.Foldable`, `Data.Traversable`, `Data.Bifoldable`, and
  `Data.Bitraversable` share some nonexported datatypes (e.g., `StateL`,
  `StateR`, `Min`, `Max`, etc.) to implement some instances. To avoid
  code duplication, I migrated this internal code to a new hidden
  module, `Data.Functor.Utils` (better naming suggestions welcome).

* `Data.Traversable` and `Data.Bitraversable` also make use of an
  identity newtype, so I modified them to use
  `Data.Functor.Identity.Identity`. This has a ripple effect on several
  other modules, since I had to move instances around in order to avoid
  dependency cycles.

Fixes #10448.

Reviewers: ekmett, hvr, austin, bgamari

Reviewed By: bgamari

Subscribers: thomie

Differential Revision: https://phabricator.haskell.org/D2284

GHC Trac Issues: #9682, #10448
15 files changed:
libraries/base/Control/Monad/Zip.hs
libraries/base/Data/Bifoldable.hs [new file with mode: 0644]
libraries/base/Data/Bitraversable.hs [new file with mode: 0644]
libraries/base/Data/Data.hs
libraries/base/Data/Foldable.hs
libraries/base/Data/Functor/Identity.hs
libraries/base/Data/Functor/Utils.hs [new file with mode: 0644]
libraries/base/Data/Semigroup.hs
libraries/base/Data/String.hs
libraries/base/Data/Traversable.hs
libraries/base/base.cabal
libraries/base/changelog.md
testsuite/tests/annotations/should_fail/annfail10.stderr
testsuite/tests/perf/compiler/all.T
testsuite/tests/typecheck/should_fail/T10971b.stderr