Skip to content

Commit

Permalink
Draft: Support OpaqueP
Browse files Browse the repository at this point in the history
The `OPAQUE` pragma was introduced in GHC 9.4.

TODO RGS: Add test case once https://gitlab.haskell.org/ghc/ghc/-/issues/21463 is fixed upstream

Addresses one part of #157.
  • Loading branch information
RyanGlScott committed May 19, 2022
1 parent 0c9c26d commit e553770
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 1 deletion.
3 changes: 2 additions & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ Version 1.14 [????.??.??]
to two arguments, just like `InfixT` is desugared. Similarly, attempting to
desugar a `PromotedUInfixT` results in an error, just like attempting to
desugar a `UInfixT` would be.
* `th-desugar` now supports `DefaultD` (i.e., `default` declarations).
* `th-desugar` now supports `DefaultD` (i.e., `default` declarations) and
`OpaqueP` (i.e., `OPAQUE` pragmas), which were added in GHC 9.4.
* Fix an inconsistency which caused non-exhaustive `case` expressions to be
desugared into uses of `EmptyCase`. Non-exhaustive `case` expressions are now
desugared into code that throws a "`Non-exhaustive patterns in...`" error at
Expand Down
1 change: 1 addition & 0 deletions Language/Haskell/TH/Desugar/AST.hs
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ data DPragma = DInlineP Name Inline RuleMatch Phases
| DAnnP AnnTarget DExp
| DLineP Int String
| DCompleteP [Name] (Maybe Name)
| DOpaqueP Name
deriving (Eq, Show, Data, Generic)

-- | Corresponds to TH's @RuleBndr@ type.
Expand Down
3 changes: 3 additions & 0 deletions Language/Haskell/TH/Desugar/Core.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1012,6 +1012,9 @@ dsPragma (LineP n str) = return $ DLineP n str
#if __GLASGOW_HASKELL__ >= 801
dsPragma (CompleteP cls mty) = return $ DCompleteP cls mty
#endif
#if __GLASGOW_HASKELL__ >= 903
dsPragma (OpaqueP n) = return $ DOpaqueP n
#endif

-- | Desugar a @RuleBndr@.
dsRuleBndr :: DsMonad q => RuleBndr -> q DRuleBndr
Expand Down
5 changes: 5 additions & 0 deletions Language/Haskell/TH/Desugar/Sweeten.hs
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,11 @@ pragmaToTH (DCompleteP {}) = error "COMPLETE pragmas only supported in GHC 8.2+"
#else
pragmaToTH (DCompleteP cls mty) = CompleteP cls mty
#endif
#if __GLASGOW_HASKELL__ >= 903
pragmaToTH (DOpaqueP n) = OpaqueP n
#else
pragmaToTH (DOpaqueP {}) = error "OPAQUE pragmas only supported in GHC 9.4+"
#endif

ruleBndrToTH :: DRuleBndr -> RuleBndr
ruleBndrToTH (DRuleVar n) = RuleVar n
Expand Down

0 comments on commit e553770

Please sign in to comment.