Skip to content

Permit bundling pattern synonyms with type synonyms

Motivation

When mtl moved from v1 to v2, 'State' became a mere type synonym and we lost the 'State' data constructor.

Now we have pattern synonyms and could almost restore the appearance and teachability of the world before:

So I can export

module Control.Monad.Trans.State
  ( State
  , pattern State
  , StateT(..)
  ...
  ) where

but since I can't bundle the State pattern with the State type, a careful user who imports State(..) fails to get a way to construct/deconstruct one.

This sort of thing happens over and over again as folks refactor APIs. Whenever I do so, I inevitably get complaints from users who use explicit minimal imports, who then have to CPP around the issue or import the pattern explicitly, or give up on their carefully crafted narrow imports.

Proposal

I'd like to just be able to bundle pattern synonyms with type synonyms, not only with data types.

This has been just a low-key wart for a long time, but it doesn't seem like it should be too hard to just allow as it only affects the import/export syntax. It almost seems harder to explicitly block this and provide the current behavior.

Edited by Edward Kmett
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information