From 469f6ddf446ffa6a772cff58cab40f3e4661ebf6 Mon Sep 17 00:00:00 2001 From: quasicomputational Date: Tue, 11 Sep 2018 09:36:57 +0100 Subject: [PATCH] Move to megaparsec version 7.0.0. (#565) * Move to megaparsec version 7.0.0. * Add megaparsec.nix --- dhall.cabal | 2 +- nix/megaparsec.nix | 25 +++++++++++++++++++++++++ src/Dhall/Parser.hs | 4 ++-- src/Dhall/Parser/Combinators.hs | 6 +++--- src/Dhall/Parser/Expression.hs | 4 ++-- stack.yaml | 8 +++++++- 6 files changed, 40 insertions(+), 9 deletions(-) create mode 100644 nix/megaparsec.nix diff --git a/dhall.cabal b/dhall.cabal index 1c818ad..42cb495 100644 --- a/dhall.cabal +++ b/dhall.cabal @@ -185,7 +185,7 @@ Library haskeline >= 0.7.3.0 && < 0.8 , insert-ordered-containers >= 0.2.1.0 && < 0.3 , lens-family-core >= 1.0.0 && < 1.3 , - megaparsec >= 6.1.1 && < 6.6 , + megaparsec >= 7.0.0 && < 7.1 , memory >= 0.14 && < 0.15, mtl >= 2.2.1 && < 2.3 , optparse-applicative < 0.15, diff --git a/nix/megaparsec.nix b/nix/megaparsec.nix new file mode 100644 index 0000000..ec94fc2 --- /dev/null +++ b/nix/megaparsec.nix @@ -0,0 +1,25 @@ +{ mkDerivation, base, bytestring, case-insensitive, containers +, criterion, deepseq, hspec, hspec-expectations, mtl +, parser-combinators, QuickCheck, scientific, stdenv, text +, transformers, weigh +}: +mkDerivation { + pname = "megaparsec"; + version = "7.0.0"; + sha256 = "bfd6870d468d680e5ca8845afb8c871d8e40231ae95a977407c371c251cc3380"; + libraryHaskellDepends = [ + base bytestring case-insensitive containers deepseq mtl + parser-combinators scientific text transformers + ]; + testHaskellDepends = [ + base bytestring case-insensitive containers hspec + hspec-expectations mtl parser-combinators QuickCheck scientific + text transformers + ]; + benchmarkHaskellDepends = [ + base containers criterion deepseq text weigh + ]; + homepage = "https://github.com/mrkkrp/megaparsec"; + description = "Monadic parser combinators"; + license = stdenv.lib.licenses.bsd2; +} diff --git a/src/Dhall/Parser.hs b/src/Dhall/Parser.hs index 29ce012..b592625 100644 --- a/src/Dhall/Parser.hs +++ b/src/Dhall/Parser.hs @@ -41,13 +41,13 @@ exprA = completeExpression -- | A parsing error data ParseError = ParseError - { unwrap :: Text.Megaparsec.ParseError Char Void + { unwrap :: Text.Megaparsec.ParseErrorBundle Text Void , input :: Text } instance Show ParseError where show (ParseError {..}) = - "\n\ESC[1;31mError\ESC[0m: Invalid input\n\n" <> Text.Megaparsec.parseErrorPretty' input unwrap + "\n\ESC[1;31mError\ESC[0m: Invalid input\n\n" <> Text.Megaparsec.errorBundlePretty unwrap instance Exception ParseError diff --git a/src/Dhall/Parser/Combinators.hs b/src/Dhall/Parser/Combinators.hs index 682031e..5a5582b 100644 --- a/src/Dhall/Parser/Combinators.hs +++ b/src/Dhall/Parser/Combinators.hs @@ -87,13 +87,13 @@ instance Text.Parser.Combinators.Parsing Parser where notFollowedBy = Text.Megaparsec.notFollowedBy instance Text.Parser.Char.CharParsing Parser where - satisfy = Parser . Text.Megaparsec.Char.satisfy + satisfy = Parser . Text.Megaparsec.satisfy char = Text.Megaparsec.Char.char notChar = Text.Megaparsec.Char.char - anyChar = Text.Megaparsec.Char.anyChar + anyChar = Text.Megaparsec.anySingle string = fmap Data.Text.unpack . Text.Megaparsec.Char.string . fromString @@ -102,7 +102,7 @@ instance Text.Parser.Char.CharParsing Parser where instance TokenParsing Parser where someSpace = Text.Parser.Token.Style.buildSomeSpaceParser - (Parser (Text.Megaparsec.skipSome (Text.Megaparsec.Char.satisfy Data.Char.isSpace))) + (Parser (Text.Megaparsec.skipSome (Text.Megaparsec.satisfy Data.Char.isSpace))) Text.Parser.Token.Style.haskellCommentStyle highlight _ = id diff --git a/src/Dhall/Parser/Expression.hs b/src/Dhall/Parser/Expression.hs index b0e95fd..ee8ebe3 100644 --- a/src/Dhall/Parser/Expression.hs +++ b/src/Dhall/Parser/Expression.hs @@ -29,9 +29,9 @@ import Dhall.Parser.Token noted :: Parser (Expr Src a) -> Parser (Expr Src a) noted parser = do - before <- Text.Megaparsec.getPosition + before <- Text.Megaparsec.getSourcePos (tokens, e) <- Text.Megaparsec.match parser - after <- Text.Megaparsec.getPosition + after <- Text.Megaparsec.getSourcePos let src₀ = Src before after tokens case e of Note src₁ _ | src₀ == src₁ -> return e diff --git a/stack.yaml b/stack.yaml index 1dc3bf2..115bd78 100644 --- a/stack.yaml +++ b/stack.yaml @@ -1,6 +1,12 @@ resolver: lts-12.4 extra-deps: - - serialise-0.2.0.0 + - megaparsec-7.0.0@rev:0 + # Version 0.2.0.0 of cborg, the latest on Hackage, is broken on i386. + - github: well-typed/cborg + commit: master + subdirs: + - cborg + - serialise nix: packages: - ncurses