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

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


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?



More information about the Libraries mailing list