Commit b94a46fd authored by Hans-Peter Deifel's avatar Hans-Peter Deifel
Browse files

Port parsers to megaparsec-7.0

parent 8ccc55b4
......@@ -91,7 +91,7 @@ library
, mtl
, extra
, containers
, megaparsec >= 6.5 && < 7.0
, megaparsec >= 7 && <8
, deriving-compat
, ieee754
ghc-options: -Wall -Wno-name-shadowing
......@@ -159,8 +159,8 @@ test-suite spec
, vector-algorithms
, bytestring
, text
, megaparsec >= 6.5 && < 7.0
, hspec-megaparsec
, megaparsec >= 7 && <8
, hspec-megaparsec >= 2.0 && <2.1
, microlens-platform
, unordered-containers
, containers
......@@ -213,7 +213,7 @@ benchmark bench
, ma
, criterion
, text
, megaparsec >= 6.5 && < 7.0
, megaparsec >= 7 && <8
, deepseq
, vector
, mtl
......@@ -231,7 +231,7 @@ executable prism-converter
build-depends: base >= 4.11
, text
, vector
, megaparsec >= 6.5 && < 7.0
, megaparsec >= 7
, containers
, optparse-applicative
, prettyprinter
......
......@@ -120,7 +120,7 @@ parseMorphisms ::
=> FunctorExpression f Sort
-> String
-> Text
-> Either (ParseError Char Void) ( SymbolTable
-> Either (ParseErrorBundle Text Void) ( SymbolTable
, Encoding (Label (Desorted f)) (H1 (Desorted f)))
parseMorphisms = parse . morphismsParser
......
......@@ -68,7 +68,7 @@ parseFunctor name input =
(Polynomial
(Sum (E.fromList [Product (E.fromList [Identity Variable])]))))
in bimap
parseErrorPretty
errorBundlePretty
id
(parse (functorExpressionParser identity functorParsers) name input)
where
......@@ -89,7 +89,7 @@ parseCoalgebra functor name input =
(Sum (E.fromList [Product (E.fromList [Identity Variable])]))))
eitherFunctor = maybe (Left (identity, functorParsers)) Right functor
in bimap
parseErrorPretty
errorBundlePretty
(Proxy, )
(parse (coalgebraParser eitherFunctor) name input)
where
......
......@@ -15,6 +15,6 @@ type ParserT = ParsecT Void Text
type Parser = Parsec Void Text
type ParseErr = ParseError Char Void
type ParseErr = ParseErrorBundle Text Void
type MonadParser = MonadParsec Void Text
......@@ -118,7 +118,7 @@ parseInput file parser = do
case parse (parser <* eof) name input of
Left err -> do
hPutStr stderr (parseErrorPretty err)
hPutStr stderr (errorBundlePretty err)
exitFailure
Right res ->
return res
......
......@@ -69,7 +69,7 @@ varIndicesP = S.fromList <$> nameP `sepBy` symbolP ","
parseVarIndices :: String -> Either String (Set Text)
parseVarIndices input =
first (parseErrorPretty) (parse (varIndicesP <* eof) input (T.pack input))
first errorBundlePretty (parse (varIndicesP <* eof) input (T.pack input))
----------------------------------------------------------------------
-- Partitioning
......
......@@ -190,7 +190,7 @@ instance ParseMorphism SomeFunctor where
parsing :: (Functor f, ParseMorphism f) => FunctorExpression f Sort
-> Text
-> Either (ParseError Char Void) (Encoding (Sorted (Label f)) (Sorted (H1 f)))
-> Either (ParseErrorBundle Text Void) (Encoding (Sorted (Label f)) (Sorted (H1 f)))
parsing expr = fmap snd . parseMorphisms expr ""
......
......@@ -11,7 +11,7 @@ import qualified Data.List.NonEmpty as NonEmpty
import Data.Proxy
import Type.Reflection
import Text.Megaparsec (parseErrorPretty)
import Text.Megaparsec (errorBundlePretty)
import Data.Vector (Vector)
import qualified Data.Vector as V
import Data.Text (Text)
......@@ -133,7 +133,7 @@ functorExpressionSpec = describe "functorExpression" $ do
-- "X" as functor.
it "gives a useful error message for non-unique keys" $ do
let Left err = p "X^{a, a}"
parseErrorPretty err `shouldSatisfy` ("unique" `isInfixOf`)
errorBundlePretty err `shouldSatisfy` ("unique" `isInfixOf`)
it "allows to use intergers as set for constants" $ do
p "Z" `shouldParse` (Functor 1 (mkPoly [[Const IntSet]]))
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment