diff --git a/CHANGES.md b/CHANGES.md index b4b5d77..37e4a20 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -3,6 +3,7 @@ Version 1.18 [????.??.??] ------------------------- +* Support GHC 9.12. * The `DLamE` and `DCaseE` data constructors (as well as the related `mkDLamEFromDPats` function) are now deprecated in favor of the new `DLamCasesE` data constructor. `DLamE`, `DCaseE`, and `mkDLamEFromDPats` will diff --git a/Language/Haskell/TH/Desugar/Core.hs b/Language/Haskell/TH/Desugar/Core.hs index 93fa516..ed0bc3f 100644 --- a/Language/Haskell/TH/Desugar/Core.hs +++ b/Language/Haskell/TH/Desugar/Core.hs @@ -686,6 +686,10 @@ dsPat (InvisP ty) = DInvisP <$> dsType ty #endif dsPat (ViewP _ _) = fail "View patterns are not supported in th-desugar. Use pattern guards instead." +#if __GLASGOW_HASKELL__ >= 911 +dsPat (OrP _) = + fail "Or-patterns are not supported in th-desugar. Use pattern guards instead." +#endif -- | Convert a 'DPat' to a 'DExp'. Fails on 'DWildP' and 'DInvisP'. dPatToDExp :: DPat -> DExp diff --git a/Language/Haskell/TH/Desugar/Util.hs b/Language/Haskell/TH/Desugar/Util.hs index d24e9af..c3bcbac 100644 --- a/Language/Haskell/TH/Desugar/Util.hs +++ b/Language/Haskell/TH/Desugar/Util.hs @@ -1113,6 +1113,9 @@ extractBoundNamesPat (UnboxedSumP pat _ _) = extractBoundNamesPat pat extractBoundNamesPat (TypeP _) = OS.empty extractBoundNamesPat (InvisP _) = OS.empty #endif +#if __GLASGOW_HASKELL__ >= 911 +extractBoundNamesPat (OrP pats) = foldMap extractBoundNamesPat pats +#endif ---------------------------------------- -- General utility diff --git a/README.md b/README.md index ca052ca..e85ee43 100644 --- a/README.md +++ b/README.md @@ -363,10 +363,12 @@ potentially recognize this and perform a more sophisticated analysis to detect and remove such matches when desugaring guards, but it currently doesn't do such an analysis. -## No support for view patterns +## No support for view patterns or Or-patterns + +`th-desugar` does not support desugaring view patterns or Or-patterns. An +alternative to using view patterns or Or-patterns in the patterns of a function +is to use pattern guards. -`th-desugar` does not support desugaring view patterns. An alternative to using -view patterns in the patterns of a function is to use pattern guards. Currently, there is not a viable workaround for using view patterns in pattern synonym definitions—see [this `th-desugar` issue](https://github.com/goldfirere/th-desugar/issues/174).