Skip to content
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

Build Alternate Number Format Plugin with GHC 9.2 #2696

Merged
merged 1 commit into from
Feb 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion cabal-ghc921.project
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ constraints:
-- These plugins don't build/work on GHC92 yet
haskell-language-server
+ignore-plugins-ghc-bounds
-alternateNumberFormat
-brittany
-class
-eval
Expand Down
8 changes: 8 additions & 0 deletions ghcide/src/Development/IDE/GHC/Compat/Core.hs
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,9 @@ module Development.IDE.GHC.Compat.Core (
ImportSpec(..),
-- * SourceText
SourceText(..),
#if !MIN_VERSION_ghc(9,2,0)
rationalFromFractionalLit,
#endif
-- * Name
tyThingParent_maybe,
-- * Ways
Expand Down Expand Up @@ -1076,3 +1079,8 @@ collectHsBindsBinders x = GHC.collectHsBindsBinders CollNoDictBinders x
pattern HsLet xlet localBinds expr <- GHC.HsLet xlet (SrcLoc.unLoc -> localBinds) expr
pattern LetStmt xlet localBinds <- GHC.LetStmt xlet (SrcLoc.unLoc -> localBinds)
#endif

#if !MIN_VERSION_ghc(9,2,0)
rationalFromFractionalLit :: FractionalLit -> Rational
rationalFromFractionalLit = fl_value
#endif
6 changes: 6 additions & 0 deletions plugins/hls-alternate-number-format-plugin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,9 @@ To generate suggestions, the plugin leverages the `Numeric` package which provid
## Changelog
### 1.0.0.0
- First Release

### 1.0.1.0
- Dependency upgrades

### 1.0.1.1
- Buildable with GHC 9.2
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cabal-version: 2.4
name: hls-alternate-number-format-plugin
version: 1.0.1.0
version: 1.0.1.1
synopsis: Provide Alternate Number Formats plugin for Haskell Language Server
description:
Please see the README on GitHub at <https://github.com/haskell/haskell-language-server#readme>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ fromIntegralLit :: RealSrcSpan -> IntegralLit -> Maybe Literal
fromIntegralLit s IL{..} = fmap (\txt' -> IntLiteral s txt' il_value) (fromSourceText il_text)

fromFractionalLit :: RealSrcSpan -> FractionalLit -> Maybe Literal
fromFractionalLit s FL{..} = fmap (\txt' -> FracLiteral s txt' fl_value) (fromSourceText fl_text)
fromFractionalLit s fl@FL{fl_text} = fmap (\txt' -> FracLiteral s txt' (rationalFromFractionalLit fl)) (fromSourceText fl_text)

fromSourceText :: SourceText -> Maybe Text
fromSourceText = \case
Expand Down Expand Up @@ -116,5 +116,5 @@ literalToString = \case
overLitToString :: OverLitVal -> String
overLitToString = \case
HsIntegral int -> case int of { IL{il_value} -> "IntegralOverLit: " <> show il_value}
HsFractional frac -> case frac of { FL{fl_value} -> "RationalOverLit: " <> show fl_value}
HsFractional frac -> case frac of { fl -> "RationalOverLit: " <> show (rationalFromFractionalLit fl)}
HsIsString _ str -> "HIsString: " <> show str