Skip to content

Remove quantified constraints in FieldGrammar#11729

Open
leana8959 wants to merge 1 commit intohaskell:masterfrom
leana8959:remove-fg-quantified-constraints
Open

Remove quantified constraints in FieldGrammar#11729
leana8959 wants to merge 1 commit intohaskell:masterfrom
leana8959:remove-fg-quantified-constraints

Conversation

@leana8959
Copy link
Copy Markdown
Collaborator

@leana8959 leana8959 commented Apr 10, 2026

Previously field grammar was written with quantified constraints, this PR refactors them to concrete types (there's actually not a lot of them!). This would help the exact print project and in general make it easier to scrutinize which term is requiring which constraint.

EDIT: at the request of Jappie, here's an error caused by an application of type family on a quantified constraint when implementing exact print. Removing the quantification helps the compiler resolve this constraint.

error message
src/Distribution/PackageDescription/FieldGrammar.hs:718:6: error: [GHC-73138]
     Illegal type synonym family application Annotate
                                                 mod (RelativePath from to) in instance:
        Newtype
          [Annotate mod (RelativePath from to)]
          (ListWith mod FSep (RelativePathNT from to) (RelativePath from to))
     In the quantified constraint forall from (to :: FileOrDir).
                                    Newtype
                                      [Annotate mod (RelativePath from to)]
                                      (ListWith
                                         mod FSep (RelativePathNT from to) (RelativePath from to))
      In the type signature:
        buildInfoFieldGrammar' :: forall mod
                                         c
                                         g. (FieldGrammarWith mod c g,
                                             Applicative (g mod (BuildInfoWith mod)),
                                             L.HasBuildInfoWith mod (BuildInfoWith mod),
                                             Newtype [Annotate mod LegacyExeDependency] (ListWith mod CommaFSep (Identity LegacyExeDependency) LegacyExeDependency),
                                             c (ListWith mod CommaFSep (Identity LegacyExeDependency) LegacyExeDependency),
                                             Newtype [Annotate mod ExeDependency] (ListWith mod CommaFSep (Identity ExeDependency) ExeDependency),
                                             c (ListWith mod CommaFSep (Identity ExeDependency) ExeDependency),
                                             Newtype [Annotate mod String] (ListWith mod NoCommaFSep Token' String),
                                             c (ListWith mod NoCommaFSep Token' String),
                                             Newtype [Annotate mod PkgconfigDependency] (ListWith mod CommaFSep (Identity PkgconfigDependency) PkgconfigDependency),
                                             c (ListWith mod CommaFSep (Identity PkgconfigDependency) PkgconfigDependency),
                                             forall from to.
                                             Newtype [Annotate mod (RelativePath from to)] (ListWith mod FSep (RelativePathNT from to) (RelativePath from to)),
                                             c (ListWith mod FSep (RelativePathNT Framework File) (RelativePath Framework File)),
                                             Newtype [Annotate mod (DependencyWith mod)] (ListWith mod CommaVCat (Identity (DependencyWith mod)) (DependencyWith mod)),
                                             c (ListWith mod CommaVCat (Identity (DependencyWith mod)) (DependencyWith mod))) =>
                                            g mod (BuildInfoWith mod) (BuildInfoWith mod)
    |
718 |   :: forall mod c g
    |      ^^^^^^^^^^^^^^...

This change doesn't change behaviour or interface.

  • Patches conform to the coding conventions.
  • Is this a PR that fixes CI? If so, it will need to be backported to older cabal release branches (ask maintainers for directions).

@leana8959 leana8959 changed the title Remove fg quantified constraints Remove quantified constraints in FieldGrammar Apr 10, 2026
@leana8959 leana8959 force-pushed the remove-fg-quantified-constraints branch from 4a6f208 to 2cdb355 Compare April 10, 2026 11:56
@leana8959 leana8959 marked this pull request as ready for review April 10, 2026 11:59
Copy link
Copy Markdown
Collaborator

@ffaf1 ffaf1 left a comment

Choose a reason for hiding this comment

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

Seems reasonable!

@leana8959 leana8959 marked this pull request as draft April 10, 2026 12:25
@leana8959
Copy link
Copy Markdown
Collaborator Author

leana8959 commented Apr 10, 2026

Drafting because I forgot to remove the language extension "QuantifiedConstraints".

Copy link
Copy Markdown
Collaborator

@sheaf sheaf left a comment

Choose a reason for hiding this comment

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

Yes, this looks fine (modulo actually removing the LANGUAGE pragma of course). I felt slightly bad for adding the quantified constraints in the first place; I agree it's not so bad to spell them out. Thanks!

@leana8959 leana8959 force-pushed the remove-fg-quantified-constraints branch from 2cdb355 to c0dd136 Compare April 10, 2026 12:38
@leana8959 leana8959 marked this pull request as ready for review April 10, 2026 21:39
@leana8959 leana8959 added the merge me Tell Mergify Bot to merge label Apr 11, 2026
@mergify mergify bot added the ready and waiting Mergify is waiting out the cooldown period label Apr 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge me Tell Mergify Bot to merge ready and waiting Mergify is waiting out the cooldown period

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants