packages feed

ghc-lib-parser-ex 8.10.0.3 → 8.10.0.4

raw patch · 5 files changed

+38/−4 lines, 5 filesPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

API changes (from Hackage documentation)

+ Language.Haskell.GhclibParserEx.GHC.Hs.Expr: isFieldPunUpdate :: HsRecField' (AmbiguousFieldOcc GhcPs) (LHsExpr GhcPs) -> Bool
+ Language.Haskell.GhclibParserEx.GHC.Hs.Expr: isMultiIf :: HsExpr GhcPs -> Bool
+ Language.Haskell.GhclibParserEx.GHC.Hs.Expr: isProc :: HsExpr GhcPs -> Bool
+ Language.Haskell.GhclibParserEx.GHC.Hs.Expr: isStrictMatch :: HsMatchContext RdrName -> Bool
+ Language.Haskell.GhclibParserEx.GHC.Hs.Expr: isTransStmt :: StmtLR GhcPs GhcPs (LHsExpr GhcPs) -> Bool
+ Language.Haskell.GhclibParserEx.GHC.Hs.Expr: isWholeFrac :: HsExpr GhcPs -> Bool
- Language.Haskell.GhclibParserEx.GHC.Hs.Pat: isPFieldPun :: LHsRecField GhcPs (Pat GhcPs) -> Bool
+ Language.Haskell.GhclibParserEx.GHC.Hs.Pat: isPFieldPun :: LHsRecField GhcPs (LPat GhcPs) -> Bool

Files

ChangeLog.md view
@@ -1,5 +1,13 @@ # Changelog for ghc-lib-parser-ex +## 8.10.0.4 released 2020-04-04+- Add expression predicates `isWholeFrac`, `isFieldPunUpdate`, `isStrictMatch`, `isMultiIf`, `isProc`, `isTransStmt`;+- Add pattern predicate `isPFieldPun`.++## 8.10.0.3 released 2020-04-03+- `strToPat` now returns an `LPat GhcPs`+- `parseExpression` now returns an `ParseResult (LHsExpr GhcPs)` (>= ghc-8.10)+ ## 0.20200401 released 2020-04-01  ## 8.10.0.2 released 2020-03-30
ghc-lib-parser-ex.cabal view
@@ -1,6 +1,6 @@ cabal-version: >= 1.18 name:           ghc-lib-parser-ex-version:        8.10.0.3+version:        8.10.0.4 description:    Please see the README on GitHub at <https://github.com/shayne-fletcher/ghc-lib-parser-ex#readme> homepage:       https://github.com/shayne-fletcher/ghc-lib-parser-ex#readme bug-reports:    https://github.com/shayne-fletcher/ghc-lib-parser-ex/issues
src/Language/Haskell/GhclibParserEx/GHC/Hs/Expr.hs view
@@ -10,8 +10,8 @@   isTag, isDol, isDot, isReturn, isSection, isRecConstr, isRecUpdate,   isVar, isPar, isApp, isOpApp, isAnyApp, isLexeme, isLambda, isQuasiQuote,   isDotApp, isTypeApp, isWHNF, isLCase,-  isFieldPun, isRecStmt, isParComp, isMDo, isTupleSection, isString, isPrimLiteral,-  isSpliceDecl, isFieldWildcard, isUnboxed,+  isFieldPun, isFieldPunUpdate, isRecStmt, isParComp, isMDo, isTupleSection, isString, isPrimLiteral,+  isSpliceDecl, isFieldWildcard, isUnboxed, isWholeFrac, isStrictMatch, isMultiIf, isProc, isTransStmt,   hasFieldsDotDot,   varToStr, strToVar,   fromChar@@ -44,6 +44,7 @@ import BasicTypes #endif import TysWiredIn+import Data.Ratio  -- 'True' if the provided expression is a variable with name 'tag'. isTag :: String -> LHsExpr GhcPs -> Bool@@ -83,10 +84,19 @@   _ -> False isLCase = \case (L _ HsLamCase{}) -> True; _ -> False +isStrictMatch :: HsMatchContext RdrName -> Bool+isStrictMatch FunRhs{mc_strictness=SrcStrict} = True+isStrictMatch _ = False+ -- Field is punned e.g. '{foo}'. isFieldPun :: LHsRecField GhcPs (LHsExpr GhcPs) -> Bool isFieldPun = \case (L _ HsRecField {hsRecPun=True}) -> True; _ -> False +-- Field puns in updates have a different type to field puns in+-- constructions.+isFieldPunUpdate :: HsRecField' (AmbiguousFieldOcc GhcPs) (LHsExpr GhcPs) -> Bool+isFieldPunUpdate = \case HsRecField {hsRecPun=True} -> True; _ -> False+ -- Contains a '..' as in 'Foo{..}' hasFieldsDotDot :: HsRecFields GhcPs (LHsExpr GhcPs) -> Bool hasFieldsDotDot = \case HsRecFields {rec_dotdot=Just _} -> True; _ -> False@@ -121,6 +131,15 @@ isSpliceDecl :: HsExpr GhcPs -> Bool isSpliceDecl = \case HsSpliceE{} -> True; _ -> False +isMultiIf :: HsExpr GhcPs -> Bool+isMultiIf = \case HsMultiIf{} -> True; _ -> False++isProc :: HsExpr GhcPs -> Bool+isProc = \case HsProc{} -> True; _ -> False++isTransStmt :: StmtLR GhcPs GhcPs (LHsExpr GhcPs) -> Bool+isTransStmt = \case TransStmt{} -> True; _ -> False+ -- Field has a '_' as in '{foo=_} or is punned e.g. '{foo}'. isFieldWildcard :: LHsRecField GhcPs (LHsExpr GhcPs) -> Bool isFieldWildcard = \case@@ -136,6 +155,11 @@  isUnboxed :: Boxity -> Bool isUnboxed = \case Unboxed -> True; _ -> False++isWholeFrac :: HsExpr GhcPs -> Bool+isWholeFrac (HsLit _ (HsRat _ (FL _ _ v) _)) = denominator v == 1+isWholeFrac (HsOverLit _ (OverLit _ (HsFractional (FL _ _ v)) _)) = denominator v == 1+isWholeFrac _ = False  varToStr :: LHsExpr GhcPs -> String varToStr (L _ (HsVar _ (L _ n)))
src/Language/Haskell/GhclibParserEx/GHC/Hs/Pat.hs view
@@ -101,7 +101,7 @@ #endif isPWildcard _ = False -isPFieldPun :: LHsRecField GhcPs (Pat GhcPs) -> Bool+isPFieldPun :: LHsRecField GhcPs (LPat GhcPs) -> Bool #if defined (GHCLIB_API_811) || defined (GHCLIB_API_810) isPFieldPun (L _ HsRecField {hsRecPun=True}) = True #else
test/Test.hs view
@@ -251,6 +251,8 @@   , testCase "isSpliceDecl" $ test "$(a + b)" $ assert' . isSpliceDecl . unLoc   , testCase "isQuasiQuote" $ test "[expr|1 + 2|]" $ assert' . isQuasiQuote   , testCase "isQuasiQuote" $ test "[expr(1 + 2)]" $ assert' . not . isQuasiQuote+  , testCase "isWholeFrac" $ test "3.2e1" $ assert' . isWholeFrac . unLoc+  , testCase "isWholeFrac" $ test "3.22e1" $ assert' . not . isWholeFrac . unLoc   , testCase "strToVar" $ assert' . isVar . strToVar $ "foo"   , testCase "varToStr" $ test "[]" $ assert' . (== "[]") . varToStr   , testCase "varToStr" $ test "foo" $ assert' . (== "foo") . varToStr