parsley-core 1.7.1.0 → 1.7.1.1
raw patch · 5 files changed
+49/−12 lines, 5 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- ChangeLog.md +5/−0
- parsley-core.cabal +1/−1
- src/ghc-8.10+/Parsley/Internal/Backend/Machine/Ops.hs +1/−1
- src/ghc/Parsley/Internal/Backend/Machine/THUtils.hs +40/−9
- src/ghc/Parsley/Internal/Core/Primitives.hs +2/−1
ChangeLog.md view
@@ -111,3 +111,8 @@ * Moved `parse` into core API, this will reduce the area of incompatibility. * Added `loop` combinator.++## 1.7.1.1 -- 2021-10-30++* Improved eta-reduction to handle multiple arguments.+* Added eta-reduction to constructed return continutations.
parsley-core.cabal view
@@ -5,7 +5,7 @@ -- | +------- breaking internal API changes -- | | +----- non-breaking API additions -- | | | +--- code changes with no API change-version: 1.7.1.0+version: 1.7.1.1 synopsis: A fast parser combinator library backed by Typed Template Haskell description: This package contains the internals of the @parsley@ package. .
src/ghc-8.10+/Parsley/Internal/Backend/Machine/Ops.hs view
@@ -497,7 +497,7 @@ @since 1.4.0.0 -} dynCont :: forall s o a x. MarshalOps o => StaCont s o a x -> DynCont s o a x-dynCont (StaCont sk Nothing) = dynCont# @o sk+dynCont (StaCont sk Nothing) = eta (dynCont# @o sk) dynCont (StaCont _ (Just dk)) = dk {- Log Operations =-}
src/ghc/Parsley/Internal/Backend/Machine/THUtils.hs view
@@ -1,23 +1,54 @@ {-# LANGUAGE CPP #-}+{-|+Module : Parsley.Internal.Backend.Machine.THUtils+Description : Functions for low-level template haskell manipulation+License : BSD-3-Clause+Maintainer : Jamie Willis+Stability : experimental++This module contains some Template Haskell related functions for manipulating+template haskell as a lower, combinator-based, level.++@since 1.7.0.0+-} module Parsley.Internal.Backend.Machine.THUtils (eta, unsafeCodeCoerce, unTypeCode) where import GHC.Types (TYPE)+import Control.Arrow (first)+import Language.Haskell.TH.Syntax ( Exp(AppE, LamE, VarE), Pat(VarP, BangP, SigP) #if __GLASGOW_HASKELL__ < 900-import Language.Haskell.TH.Syntax (Q, unTypeQ, unsafeTExpCoerce+ , Q, unTypeQ, unsafeTExpCoerce #else-import Language.Haskell.TH.Syntax (unTypeCode, unsafeCodeCoerce+ , unTypeCode, unsafeCodeCoerce #endif- , Exp(AppE, LamE, VarE), Pat(VarP, BangP, SigP))+ ) import Parsley.Internal.Common.Utils (Code) +{-|+Given a function (of arbitrarily many arguments, but it must at /least/ have 1), eta-reduces+it to remove redundant arguments.++@since 1.7.0.0+-} eta :: forall r1 r2 (a :: TYPE r1) (b :: TYPE r2). Code (a -> b) -> Code (a -> b)-eta = unsafeCodeCoerce . fmap checkEta . unTypeCode+eta = unsafeCodeCoerce . fmap checkEtaMulti . unTypeCode where- checkEta (LamE [VarP x] (AppE qf (VarE x'))) | x == x' = qf- checkEta (LamE [SigP (VarP x) _] (AppE qf (VarE x'))) | x == x' = qf- checkEta (LamE [BangP (VarP x)] (AppE qf (VarE x'))) | x == x' = qf- checkEta (LamE [BangP (SigP (VarP x) _)] (AppE qf (VarE x'))) | x == x' = qf- checkEta qf = qf+ -- \ x -> f x = f+ checkEta (VarP x) (AppE qf (VarE x')) | x == x' = (Nothing, qf)+ -- \ (x :: t) -> f x = f+ checkEta (SigP (VarP x) _) (AppE qf (VarE x')) | x == x' = (Nothing, qf)+ -- \ (! x) -> f x = f+ checkEta (BangP (VarP x)) (AppE qf (VarE x')) | x == x' = (Nothing, qf)+ -- \ (! x :: t) -> f x = f+ checkEta (BangP (SigP (VarP x) _)) (AppE qf (VarE x')) | x == x' = (Nothing, qf)+ -- \ x -> body = \ x -> body+ checkEta qarg qbody = (Just qarg, qbody)++ checkEtaMulti (LamE args body) = uncurry LamE $+ foldr (\arg (args, body) -> first (maybe args (: args)) (checkEta arg body))+ ([], body)+ args+ checkEtaMulti qf = qf #if __GLASGOW_HASKELL__ < 900 unsafeCodeCoerce :: Q Exp -> Code a
src/ghc/Parsley/Internal/Core/Primitives.hs view
@@ -6,6 +6,7 @@ ) where import Prelude hiding (pure, (<*>))+import Control.Arrow (first) import Parsley.Internal.Core.CombinatorAST (Combinator(..), ScopeRegister(..), Reg(..), Parser(..)) #if MIN_VERSION_parsley_core(2,0,0) import Parsley.Internal.Core.Defunc (Defunc)@@ -40,7 +41,7 @@ instance ParserOps WQ where pure = pure . BLACK satisfy = satisfy . BLACK- conditional = conditional . map (\(f, t) -> (BLACK f, t))+ conditional = conditional . map (first BLACK) instance {-# INCOHERENT #-} x ~ Defunc => ParserOps x where pure = _pure