Skip to content

Conversation

@NadiaYvette
Copy link
Contributor

@NadiaYvette NadiaYvette commented Aug 3, 2025

This is the fix mentioned for

Type inference on the unboxed types doesn't play so well with -XImpredicativeTypes, so, after creating testcases for it (one new handwritten one and converting preexisting ones by just using the language extension flag), this branch adds type annotations within C macros used in AlexWrapper.hs.

Closes #277.

@NadiaYvette NadiaYvette force-pushed the nadia.chambers/tagToEnum-annotations-001 branch 4 times, most recently from 7b6f17f to 6c3b445 Compare August 3, 2025 16:46
@NadiaYvette
Copy link
Contributor Author

The various force pushes are for build errors of my handwritten testcase with elder ghc versions.

Left e -> fail e
Right (n, txt)
| Text.null txt -> pure $ TokenInt n
| otherwise -> fail "got incomplete prefix " }
Copy link
Member

Choose a reason for hiding this comment

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

For GHC 8.4/8.6: fail -> Control.Monad.Fail.fail (or hidefail from Control.Monad).
In general, just using explicit imports makes things more robust across multiple GHC versions...

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Covered, thanks! The force push hides this as part of the history, but it covers at least Control.Monad and Control.Monad.Fail with the explicit imports.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It also comes in through Prelude; I'm just using it qualified now.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

All checks successful now.

@andreasabel andreasabel added this to the 3.5.4.0 milestone Aug 3, 2025
@andreasabel andreasabel added the bug label Aug 3, 2025
@NadiaYvette NadiaYvette force-pushed the nadia.chambers/tagToEnum-annotations-001 branch from 6c3b445 to b28363e Compare August 3, 2025 17:00
With -XImpredicativeTypes, the following occurs:

basic_typeclass.i.hs:877:28: error: [GHC-36495]
    • tagToEnum# must appear applied to one value argument
    • In the first argument of ‘(&&)’, namely
        ‘(GHC.Exts.tagToEnum# (offset >=# 0#))’
      In the expression:
        (GHC.Exts.tagToEnum# (offset >=# 0#))
          &&
            let check = alexIndexInt16OffAddr alex_check offset
            in (GHC.Exts.tagToEnum# (check ==# ord_c))
      In the expression:
        if (GHC.Exts.tagToEnum# (offset >=# 0#))
             &&
               let check = alexIndexInt16OffAddr alex_check offset
               in (GHC.Exts.tagToEnum# (check ==# ord_c)) then
            alexIndexInt16OffAddr alex_table offset
        else
            alexIndexInt16OffAddr alex_deflt s
    |
877 |                 new_s = if GTE(offset,ILIT(0))
    |                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
GTE() and EQ() were getting the following errors for the
monadUserState-strict-text and possibly other cases with
-XImpredicativeTypes enabled:

basic_typeclass.i.hs:877:28: error: [GHC-36495]
    • tagToEnum# must appear applied to one value argument
    • In the first argument of ‘(&&)’, namely
        ‘(GHC.Exts.tagToEnum# (offset >=# 0#))’
      In the expression:
        (GHC.Exts.tagToEnum# (offset >=# 0#))
          &&
            let check = alexIndexInt16OffAddr alex_check offset
            in (GHC.Exts.tagToEnum# (check ==# ord_c))
      In the expression:
        if (GHC.Exts.tagToEnum# (offset >=# 0#))
             &&
               let check = alexIndexInt16OffAddr alex_check offset
               in (GHC.Exts.tagToEnum# (check ==# ord_c)) then
            alexIndexInt16OffAddr alex_table offset
        else
            alexIndexInt16OffAddr alex_deflt s
    |
877 |                 new_s = if GTE(offset,ILIT(0))
    |                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Annotating the tagToEnum# usage to specify which Enum is intended was
one case. Another was annotating the results of ==# and >=# to resolve
some ambiguity involved there.
@NadiaYvette NadiaYvette force-pushed the nadia.chambers/tagToEnum-annotations-001 branch from b28363e to 3f0dd74 Compare August 3, 2025 17:16
Copy link
Member

@andreasabel andreasabel left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution!

@andreasabel andreasabel merged commit 3e91a9c into haskell:master Aug 3, 2025
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

-XImpredicativeTypes incompatibility

2 participants