packages feed

invertible-grammar 0.1.3.3 → 0.1.3.4

raw patch · 7 files changed

+19/−104 lines, 7 filesdep ~basedep ~bifunctorsdep ~mtlPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: base, bifunctors, mtl, prettyprinter, template-haskell, transformers

API changes (from Hackage documentation)

Files

invertible-grammar.cabal view
@@ -1,5 +1,5 @@ name:                invertible-grammar-version:             0.1.3.3+version:             0.1.3.4 license:             BSD3 license-file:        LICENSE author:              Yevhen Smolanka, Sergey Vinokurov@@ -14,7 +14,7 @@ description:   Grammar combinator framework to build invertible parsing libraries   for concrete syntax.-tested-with:   GHC == 8.4.4, GHC == 8.6.5, GHC == 8.8.4, GHC == 8.10.7, GHC == 9.0.1+tested-with:   GHC == 8.4.4, GHC == 8.6.5, GHC == 8.8.4, GHC == 8.10.7, GHC == 9.0.1, GHC == 9.2.5  source-repository head   type: git@@ -36,11 +36,11 @@     Data.InvertibleGrammar.Monad    build-depends:-      base              >=4.8   && <5.0-    , bifunctors        >=4.2   && <5.6+      base              >=4.11  && <5.0+    , bifunctors        >=4.2   && <6.0     , containers        >=0.5.5 && <0.7-    , mtl               >=2.1   && <2.4-    , prettyprinter     >=1     && <1.8+    , mtl               >=2.2   && <2.4+    , prettyprinter     >=1.7   && <2.0     , profunctors       >=4.4   && <5.7     , semigroups        >=0.16  && <0.21     , tagged            >=0.7   && <0.9
src/Control/Monad/ContextError.hs view
@@ -1,4 +1,3 @@-{-# LANGUAGE CPP                    #-} {-# LANGUAGE DeriveFunctor          #-} {-# LANGUAGE FlexibleInstances      #-} {-# LANGUAGE FunctionalDependencies #-}@@ -15,10 +14,6 @@   , MonadContextError (..)   ) where -#if !MIN_VERSION_mtl(2,2,0)-import Control.Monad.Error-#endif- import Control.Applicative import Control.Monad (MonadPlus, mplus, mzero) import Control.Monad.Trans.Class (MonadTrans, lift)@@ -39,9 +34,6 @@ import Control.Monad.Writer (MonadWriter (..))  import Data.Functor.Identity-#if !MIN_VERSION_base(4,11,0)-import Data.Semigroup-#endif  ---------------------------------------------------------------------- -- Monad@@ -78,9 +70,6 @@   {-# INLINE (<|>) #-}  instance Monad (ContextErrorT c e m) where-  return a = ContextErrorT $ \c _ ret -> ret c a-  {-# INLINE return #-}-   ma >>= fb =     ContextErrorT $ \c err ret ->       unContextErrorT ma c err $ \c' a ->@@ -147,25 +136,12 @@     localContext = Cont.liftLocal askContext localContext     modifyContext = lift . modifyContext -#if MIN_VERSION_mtl(2, 2, 0)- instance MonadContextError c e m =>          MonadContextError c e (ExceptT e m) where     throwInContext = lift . throwInContext     askContext = lift askContext     localContext = mapExceptT . localContext     modifyContext = lift . modifyContext--#else--instance (Error e', MonadContextError c e m) =>-         MonadContextError c e (ErrorT e' m) where-    throwInContext = lift . throwInContext-    askContext = lift askContext-    localContext = mapErrorT . localContext-    modifyContext = lift . modifyContext--#endif  instance MonadContextError c e m =>          MonadContextError c e (IdentityT m) where
src/Data/InvertibleGrammar/Base.hs view
@@ -1,4 +1,3 @@-{-# LANGUAGE CPP                   #-} {-# LANGUAGE DeriveFoldable        #-} {-# LANGUAGE DeriveFunctor         #-} {-# LANGUAGE DeriveTraversable     #-}@@ -18,22 +17,12 @@   ) where  import Prelude hiding ((.), id)-#if defined(__GLASGOW_HASKELL__) && __GLASGOW_HASKELL__ < 710-import Control.Applicative-#endif import Control.Category import Control.Monad import Data.Text (Text) import Data.Bifunctor import Data.Bifoldable import Data.Bitraversable-#if !MIN_VERSION_base(4,8,0)-import Data.Traversable-import Data.Foldable-#endif-#if !MIN_VERSION_base(4,11,0)-import Data.Semigroup-#endif import Data.InvertibleGrammar.Monad import qualified Debug.Trace 
src/Data/InvertibleGrammar/Combinators.hs view
@@ -1,4 +1,3 @@-{-# LANGUAGE CPP                 #-} {-# LANGUAGE OverloadedStrings   #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE Trustworthy         #-}@@ -33,10 +32,6 @@ import Data.Void import Data.Text (Text) import Data.InvertibleGrammar.Base--#if !MIN_VERSION_base(4,11,0)-import Data.Semigroup-#endif  -- | Isomorphism on the stack head. iso :: (a -> b) -> (b -> a) -> Grammar p (a :- t) (b :- t)
src/Data/InvertibleGrammar/Generic.hs view
@@ -1,4 +1,3 @@-{-# LANGUAGE CPP                    #-} {-# LANGUAGE DataKinds              #-} {-# LANGUAGE FlexibleContexts       #-} {-# LANGUAGE FlexibleInstances      #-}@@ -28,15 +27,14 @@  import Data.Functor.Identity import Data.InvertibleGrammar.Base+import Data.Kind (Type) import Data.Monoid (First(..)) import Data.Profunctor (Choice(..)) import Data.Profunctor.Unsafe import Data.Tagged import Data.Text (pack)-#if !MIN_VERSION_base(4,11,0)-import Data.Semigroup ((<>))-#endif + import GHC.Generics  -- | Provide a data constructor/stack isomorphism to a grammar working on@@ -90,17 +88,17 @@   (:++) (a ': as) bs = a ': (as :++ bs)   (:++) '[] bs = bs -type family Coll (f :: * -> *) (t :: *) :: [*] where+type family Coll (f :: Type -> Type) (t :: Type) :: [Type] where   Coll (f :+: g)  t = Coll f t :++ Coll g t   Coll (M1 D c f) t = Coll f t   Coll (M1 C c f) t = '[StackPrismLhs f t] -type family Trav (t :: * -> *) (l :: [*]) :: [*] where+type family Trav (t :: Type -> Type) (l :: [Type]) :: [Type] where   Trav (f :+: g) lst = Trav g (Trav f lst)   Trav (M1 D c f) lst = Trav f lst   Trav (M1 C c f) (l ': ls) = ls -class Match (f :: * -> *) bs t where+class Match (f :: Type -> Type) bs t where   match' :: PrismList f a          -> Coproduct p s bs a t          -> ( Grammar p s (a :- t)@@ -165,9 +163,9 @@ -- > nil  :: StackPrism              t  ([a] :- t) -- > cons :: StackPrism (a :- [a] :- t) ([a] :- t) -- > PrismList (P nil :& P cons) = mkPrismList :: StackPrisms [a]-data family PrismList (f :: * -> *) (a :: *)+data family PrismList (f :: Type -> Type) (a :: Type) -class MkPrismList (f :: * -> *) where+class MkPrismList (f :: Type -> Type) where   mkPrismList' :: (f p -> a) -> (a -> Maybe (f q)) -> PrismList f a  data instance PrismList (M1 D c f) a = PrismList (PrismList f a)@@ -208,9 +206,9 @@  -- Deriving types and conversions for single constructors -type family StackPrismLhs (f :: * -> *) (t :: *) :: *+type family StackPrismLhs (f :: Type -> Type) (t :: Type) :: Type -class MkStackPrism (f :: * -> *) where+class MkStackPrism (f :: Type -> Type) where   mkR :: forall p t. StackPrismLhs f t -> (f p :- t)   mkL :: forall p t. (f p :- t) -> StackPrismLhs f t 
src/Data/InvertibleGrammar/Monad.hs view
@@ -1,4 +1,3 @@-{-# LANGUAGE CPP               #-} {-# LANGUAGE DeriveGeneric     #-} {-# LANGUAGE FlexibleContexts  #-} {-# LANGUAGE OverloadedStrings #-}@@ -34,30 +33,12 @@ import Data.Text (Text) import GHC.Generics -#if MIN_VERSION_prettyprinter(1,7,0) import Prettyprinter   ( Doc, Pretty, pretty, vsep, hsep, line, indent, fillSep, punctuate   , comma, colon, (<+>), layoutSmart, PageWidth(..), LayoutOptions(..)   )-#else-import Data.Text.Prettyprint.Doc-  ( Doc, Pretty, pretty, vsep, hsep, line, indent, fillSep, punctuate-  , comma, colon, (<+>), layoutSmart, PageWidth(..), LayoutOptions(..)-  )-#endif -#if MIN_VERSION_prettyprinter(1,7,0) import Prettyprinter.Render.String-#elif MIN_VERSION_prettyprinter(1,2,0)-import Data.Text.Prettyprint.Doc.Render.String-#else-import Data.Text.Prettyprint.Doc (SimpleDocStream)-import Data.Text.Prettyprint.Doc.Render.ShowS--renderString :: SimpleDocStream ann -> String-renderString stream = renderShowS stream ""-#endif-  initPropagation :: p -> Propagation p initPropagation = Propagation [0] []
src/Data/InvertibleGrammar/TH.hs view
@@ -1,12 +1,8 @@-{-# LANGUAGE CPP             #-} {-# LANGUAGE LambdaCase      #-} {-# LANGUAGE TemplateHaskell #-}  module Data.InvertibleGrammar.TH where -#if defined(__GLASGOW_HASKELL__) && __GLASGOW_HASKELL__ < 710-import Control.Applicative-#endif import Data.Foldable (toList) import Data.InvertibleGrammar.Base import Data.Maybe@@ -14,9 +10,6 @@ import Language.Haskell.TH as TH import Data.Set (Set) import qualified Data.Set as S-#if !MIN_VERSION_base(4,11,0)-import Data.Semigroup ((<>))-#endif   {- | Build a prism and the corresponding grammar that will match on the@@ -44,19 +37,13 @@  grammarFor :: Name -> ExpQ grammarFor constructorName = do-#if defined(__GLASGOW_HASKELL__)-# if __GLASGOW_HASKELL__ <= 710-  DataConI realConstructorName _typ parentName _fixity <- reify constructorName-# else   DataConI realConstructorName _typ parentName <- reify constructorName-# endif-#endif   TyConI dataDef <- reify parentName -  let Just (single, constructorInfo) = do-        (single, allConstr) <- constructors dataDef-        constr <- findConstructor realConstructorName allConstr-        return (single, constr)+  (single, constructorInfo) <- maybe (fail "Could not find the constructor") pure $ do+     (single, allConstr) <- constructors dataDef+     constr <- findConstructor realConstructorName allConstr+     return (single, constr)    let ts = fieldTypes constructorInfo   vs <- mapM (const $ newName "x") ts@@ -114,15 +101,8 @@ -- Utils  constructors :: Dec -> Maybe (Bool, [Con])-#if defined(__GLASGOW_HASKELL__)-# if __GLASGOW_HASKELL__ <= 710-constructors (DataD _ _ _ cs _)     = Just (length cs == 1, cs)-constructors (NewtypeD _ _ _ c _)   = Just (True, [c])-# else constructors (DataD _ _ _ _ cs _)   = Just (length cs == 1, cs) constructors (NewtypeD _ _ _ _ c _) = Just (True, [c])-# endif-#endif constructors _                      = Nothing  findConstructor :: Name -> [Con] -> Maybe Con@@ -137,10 +117,8 @@   RecC name _      -> S.singleton name   InfixC _ name _  -> S.singleton name   ForallC _ _ con' -> constructorNames con'-#if MIN_VERSION_template_haskell(2, 11, 0)   GadtC cs _ _     -> S.fromList cs   RecGadtC cs _ _  -> S.fromList cs-#endif  fieldTypes :: Con -> [Type] fieldTypes = \case@@ -148,10 +126,8 @@   RecC _ fieldTypes     -> map extractType' fieldTypes   InfixC (_,a) _b (_,b) -> [a, b]   ForallC _ _ con'      -> fieldTypes con'-#if defined(__GLASGOW_HASKELL__) && __GLASGOW_HASKELL__ >= 800   GadtC _ fs _          -> map extractType fs   RecGadtC _ fs _       -> map extractType' fs-#endif   where     extractType (_, t) = t     extractType' (_, _, t) = t