-
Notifications
You must be signed in to change notification settings - Fork 86
tagToEnum# annotations in AlexWrapper C macros for -XImpredicativeTypes #278
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
tagToEnum# annotations in AlexWrapper C macros for -XImpredicativeTypes #278
Conversation
7b6f17f to
6c3b445
Compare
|
The various force pushes are for build errors of my handwritten testcase with elder |
tests/monadic_expr.x
Outdated
| Left e -> fail e | ||
| Right (n, txt) | ||
| | Text.null txt -> pure $ TokenInt n | ||
| | otherwise -> fail "got incomplete prefix " } |
There was a problem hiding this comment.
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...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here is the whole (hi)story: https://gitlab.haskell.org/haskell/prime/-/wikis/libraries/proposals/monad-fail#transitional-strategy
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All checks successful now.
6c3b445 to
b28363e
Compare
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.
b28363e to
3f0dd74
Compare
andreasabel
left a comment
There was a problem hiding this 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!
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 inAlexWrapper.hs.Closes #277.