Skip to content

Remove re-exports of Control.Monad, ... - #99

Merged
chessai merged 2 commits into
haskell:masterfrom
phadej:no-control-monad-exports
Nov 17, 2021
Merged

chessai merged 2 commits into
haskell:masterfrom
phadej:no-control-monad-exports

Conversation

@phadej

@phadej phadej commented Nov 14, 2021 •

Copy link
Copy Markdown
Contributor

... Control.Monad.Fix and Data.Monoid modules.

Import Identity and MonadIO explicitly
in Control.Monad.Identity and Control.Monad.Trans
to avoid potential future API fluctuations.

Resolves #68

@phadej
phadej force-pushed the no-control-monad-exports branch from a44cd3a to 930cda7 Compare November 14, 2021 19:40
@phadej

phadej commented Nov 14, 2021

Copy link
Copy Markdown
Contributor Author

I'd actually prefer to not re-export MonadTrans either, especially as whether it has QuantifiedConstraint depends on the underlying transformers version (as non-transformers-0.6 are also allowed). But maybe that can wait for the next major version.

Comment thread Control/Monad/Identity.hs Resolved
... Control.Monad.Fix and Data.Monoid modules.

Import Identity, MonadIO, MonadTrans explicitly
in Control.Monad.Identity, Control.Monad.Trans
and other modules to avoid potential future API fluctuations.
@phadej
phadej force-pushed the no-control-monad-exports branch from 930cda7 to cba4b82 Compare November 15, 2021 14:28
Comment thread Control/Monad/Identity.hs Resolved
@emilypi

emilypi commented Nov 17, 2021

Copy link
Copy Markdown
Member

@phadej approved with one small grammatical wibble

@chessai

chessai commented Nov 17, 2021

Copy link
Copy Markdown
Member

LGTM pending Emily's comments.

@chessai
chessai merged commit 9e1582a into haskell:master Nov 17, 2021
@phadej
phadej deleted the no-control-monad-exports branch November 17, 2021 23:05
@sjakobi

sjakobi commented Nov 19, 2021 •

Copy link
Copy Markdown
Member

I've noticed some breakage due to this change. See #101.

@phadej

phadej commented Nov 19, 2021

Copy link
Copy Markdown
Contributor Author

E.g. lucid imports MonadIO through Control.Monad.Reader. This is IMHO surprising.

Having an explicit set list of re-exports is an option too. Though #68 would repeat when e.g. base-compat exports MonadFail.fail and Control.Monad.Reader would export old Control.Monad.fail (on base where it exists).

import Control.Monad.Writer.Class

import Control.Monad.Trans
import Control.Monad.Trans (MonadTrans (lift))

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Control.Monad.Trans used to re-export MonadIO(liftIO) too. I don't think that is a good idea. MonadTrans(lift) is somewhat justified, but MonadIO seems to be there out-of-blue.

@phadej

phadej commented Nov 19, 2021

Copy link
Copy Markdown
Contributor Author

Re explicit export list: Note that Control.Monad has functions like:

msum :: MonadPlus m => [m a] -> m a

which changed its type to

msum :: (MonadPlus m, Foldable t) => f (m a) -> m a

also foldM is similarly Foldable-generalized. Also forever, guard are generalized to Applicative / Alternative.

Also the <$!> is present since base-4.8.0.0 only.

We could either:

  1. not re-export these functions
  2. redefine them to always have "new" types
  3. drop support from pre-AMP GHCs.

All of these would still preserve a potential problem that a future base change would force a major version of mtl due change in type. (Or mtl could continue to re-export the name with an old type, if possible).


TBH, I looks like there are only bad options

  • Try to not break downstream, making maintenance harder (the base <5 bound won't cut, has to be reviewed every major base release, if there are explicit re-export lists)
  • Annoy folks buy cleaning up the API surface.

Long term the latter is better, but right now is quite a bad moment for that :(

@sjakobi

sjakobi commented Nov 19, 2021 via email

Copy link
Copy Markdown
Member

@phadej

phadej commented Nov 19, 2021

Copy link
Copy Markdown
Contributor Author

As I said, this will just delay the "inevitable". Folks shouldn't import Control.Monad.State etc unqualified and also expect to get MonadIO from there. That's unhygienic and bad API design.

I'd rather do this right at once. If now is a bad moment (due Eq drama and no decision on how much breakage is acceptable, e.g.) I'd rather revert this commit (an re-open #68) than go for suboptimal middle-ground. Still re-exporting something is a baby step which doesn't really bring closer to resolving #68.

@sjakobi

sjakobi commented Nov 22, 2021

Copy link
Copy Markdown
Member

Still re-exporting something is a baby step which doesn't really bring closer to resolving #68.

I don't understand this. It seems quite viable to find a set of re-exports that would substantially reduce the breakage I reported in #101, and at the same time avoid the PVP problems reported in #68.

In principle I agree that mtl shouldn't have these re-exports at all, but the current situation is that lots of packages depend on these now.

I'm not fundamentally opposed to getting rid of the re-exports eventually, but I think it should be done separately from the migration to transformers-0.6. Otherwise this migration will be extremely slow and painful.

@phadej

phadej commented Nov 22, 2021 •

Copy link
Copy Markdown
Contributor Author

Otherwise this migration will be extremely slow and painful.

This is "break big but rarely" vs. "break often in small parts" trade-off. In general people prefer no breakages at all.

Otherwise this migration will be extremely slow and painful.

For the removal of re-exports change the migration is adding

import Control.Monad

like import on top of

import Control.Monad.Reader

Not painful. Requires more packages to be patched, but if we are going to do that anyway, why not now?

Anyway. I won't write a patch for a set of re-exports that..., and I'm fine with this patch being reverted if it's a blocker for release of mtl. But this is up to actual maintainers of mtl whom have been silent for now. I think we discussed this enough so they can make a call what they would prefer to do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MTL doesn't adhere to PVP as it re-exports e.g. Control.Monad

5 participants