Stop the deprecation of Data.Monoid.{First,Last}

Simon Jakobi simon.jakobi at googlemail.com
Sat Apr 11 03:29:33 UTC 2020


Hi!

For two years there has been a plan ([1], [12]) to deprecate and
eventually remove Data.Monoid.{First,Last} ([13]), in order to resolve
the name conflict with Data.Semigroup.{First,Last} ([14]).

While implementing ([2]) this plan in GHC and the core libraries, and
testing the migration in a few packages, I encountered some
difficulties which made me question whether the benefits of the
deprecation would outweigh its costs:

* Code that previously used Data.Monoid.{First,Last} becomes noisier.
See e.g. a patch to migrate the summoner package ([3]).

* Higher Kinded Data applications of D.M.{First,Last} such as in
higgledy ([4]) are difficult to migrate, partly due to missing
instances for D.S.{First,Last} ([5]).

* Additionally, there's an important difference in the strictness of
the Semigroup instances for D.M.{First.Last} and the suggested
replacement of (Maybe D.S.{First,Last}): [6], [9].

In sum, the existing migration story is painful in multiple ways.

Moreover, D.S.{First,Last} don't actually seem to be useful in
practice. I couldn't find any code using them except to define the
usual newtype instances.

In consequence, I think the deprecation should be scrapped, and the
documentation of base updated accordingly.

Regarding alternative ways to resolve the name clash, I see the
following options:

A) Deprecate and remove D.S.{First,Last}.
B) Rename D.S.{First,Last}.
C) Do nothing. Haskellers are already used to handling the name clash,
usually via qualified imports.

I would also like to mention that the process surrounding the
deprecation has IMHO been somewhat less than ideal:

1. The deprecation was apparently decided without much research on how
D.M.{First,Last} are being used in the ecosystem, and without properly
testing the suggested migration.

2. Apart from the brief discussion on the libraries mailing list and
changes to the haddocks ([7], [8]) for D.M.{First,Last}, there appears
not to have been any announcement of the planned deprecation.

3. When, shortly after the haddocks changes, the strictness
differences between D.M.First and (Maybe D.S.First) were pointed out
on the libraries mailing list ([9]), the deprecation was apparently
not reconsidered, nor the documentation updated. I myself wasn't aware
of this aspect while I worked on the deprecation!

4. I should have sent this email 9 months ago, when I stopped working
on the deprecation. The incorrect information in the haddocks has
since caused some confusion ([10], [11]).

What do you think?

Cheers,
Simon

[1] https://mail.haskell.org/pipermail/libraries/2018-April/028712.html
[2] https://gitlab.haskell.org/ghc/ghc/-/merge_requests/842
[3] https://github.com/kowainik/summoner/pull/319
[4] https://github.com/i-am-tom/higgledy/issues/4
[5] https://gitlab.haskell.org/ghc/ghc/issues/16636
[6] https://gitlab.haskell.org/ghc/ghc/issues/17967
[7] https://gitlab.haskell.org/ghc/ghc/-/commit/e34e30e492a7bc40e3da5a05b8e297acb0aeeadc
[8] https://gitlab.haskell.org/ghc/ghc/-/commit/cf35ab9ac7e0f33e39af6af16ecf850e24c2cb79
[9] https://mail.haskell.org/pipermail/libraries/2018-May/028818.html
[10] https://github.com/conal/checkers/issues/44
[11] https://gitlab.haskell.org/ghc/ghc/issues/18041
[12] https://gitlab.haskell.org/ghc/ghc/issues/15028
[13] http://downloads.haskell.org/~ghc/8.10.1/docs/html/libraries/base-4.14.0.0/Data-Monoid.html#t:First
[14] http://downloads.haskell.org/~ghc/8.10.1/docs/html/libraries/base-4.14.0.0/Data-Semigroup.html#t:First


More information about the Libraries mailing list