From 96d306255081929812feb4207b4fe8b9f9d27645 Mon Sep 17 00:00:00 2001 From: Brent Yorgey Date: Wed, 8 Nov 2023 12:26:23 -0600 Subject: [PATCH] update to `megaparsec-9.6.1` (#1609) * Update to `megaparsec-9.6.1`. This allows us to remove any annoying workaround. * Bump stack resolver to LTS-21.19. * Drop support for GHC 8.10. --- .github/workflows/haskell-ci.yml | 5 ----- .mergify.yml | 2 -- src/Swarm/Language/Parse.hs | 20 +++++--------------- stack.yaml | 3 ++- swarm.cabal | 4 ++-- 5 files changed, 9 insertions(+), 25 deletions(-) diff --git a/.github/workflows/haskell-ci.yml b/.github/workflows/haskell-ci.yml index e7ab7ec7..5037836e 100644 --- a/.github/workflows/haskell-ci.yml +++ b/.github/workflows/haskell-ci.yml @@ -77,11 +77,6 @@ jobs: compilerVersion: 9.0.2 setup-method: ghcup allow-failure: false - - compiler: ghc-8.10.7 - compilerKind: ghc - compilerVersion: 8.10.7 - setup-method: ghcup - allow-failure: false fail-fast: false steps: - name: apt diff --git a/.mergify.yml b/.mergify.yml index d6bd18ea..448c4088 100644 --- a/.mergify.yml +++ b/.mergify.yml @@ -18,7 +18,6 @@ queue_rules: - check-success=Haskell-CI - Linux - ghc-9.4.5 - check-success=Haskell-CI - Linux - ghc-9.2.7 - check-success=Haskell-CI - Linux - ghc-9.0.2 - - check-success=Haskell-CI - Linux - ghc-8.10.7 pull_request_rules: - actions: @@ -49,7 +48,6 @@ pull_request_rules: - check-success=Haskell-CI - Linux - ghc-9.4.5 - check-success=Haskell-CI - Linux - ghc-9.2.7 - check-success=Haskell-CI - Linux - ghc-9.0.2 - - check-success=Haskell-CI - Linux - ghc-8.10.7 - label=merge me - ! '#approved-reviews-by>=1' - ! '#changes-requested-reviews-by=0' diff --git a/src/Swarm/Language/Parse.hs b/src/Swarm/Language/Parse.hs index 982d3169..67f3d57d 100644 --- a/src/Swarm/Language/Parse.hs +++ b/src/Swarm/Language/Parse.hs @@ -60,6 +60,7 @@ import Text.Megaparsec hiding (runParser) import Text.Megaparsec.Char import Text.Megaparsec.Char.Lexer qualified as L import Text.Megaparsec.Pos qualified as Pos +import Text.Megaparsec.State (initialPosState, initialState) import Witch -- Imports for doctests (cabal-docspec needs this) @@ -486,24 +487,13 @@ runParserTH (file, line, col) p s = Left err -> fail $ errorBundlePretty err Right e -> return e where - -- This is annoying --- megaparsec does not export its function to - -- construct an initial parser state, so we can't just use that - -- and then change the one field we need to be different (the - -- 'pstateSourcePos'). We have to copy-paste the whole thing. initState :: State Text Void initState = - State - { stateInput = from s - , stateOffset = 0 - , statePosState = - PosState - { pstateInput = from s - , pstateOffset = 0 - , pstateSourcePos = SourcePos file (mkPos line) (mkPos col) - , pstateTabWidth = defaultTabWidth - , pstateLinePrefix = "" + (initialState file (from s)) + { statePosState = + (initialPosState file (from s)) + { pstateSourcePos = SourcePos file (mkPos line) (mkPos col) } - , stateParseErrors = [] } -- | Parse some input 'Text' completely as a 'Term', consuming leading diff --git a/stack.yaml b/stack.yaml index 4d7e157a..b00ae6bd 100644 --- a/stack.yaml +++ b/stack.yaml @@ -10,6 +10,7 @@ extra-deps: # breaking changes; see https://github.com/swarm-game/swarm/issues/1350 - lsp-1.6.0.0 - lsp-types-1.6.0.0 +- megaparsec-9.6.1 - AhoCorasick-0.0.4 -resolver: lts-21.0 +resolver: lts-21.19 diff --git a/swarm.cabal b/swarm.cabal index 6617419e..5167132f 100644 --- a/swarm.cabal +++ b/swarm.cabal @@ -32,7 +32,7 @@ maintainer: byorgey@gmail.com bug-reports: https://github.com/swarm-game/swarm/issues copyright: Brent Yorgey 2021 category: Game -tested-with: GHC ==8.10.7 || ==9.0.2 || ==9.2.7 || ==9.4.5 || ==9.6.2 +tested-with: GHC ==9.0.2 || ==9.2.7 || ==9.4.5 || ==9.6.2 extra-source-files: CHANGELOG.md example/*.sw editors/emacs/*.el @@ -277,7 +277,7 @@ library lens >= 4.19 && < 5.3, linear >= 1.21.6 && < 1.23, lsp >= 1.6 && < 1.7, - megaparsec >= 9.0 && < 9.6, + megaparsec >= 9.6.1 && < 9.7, minimorph >= 0.3 && < 0.4, transformers >= 0.5 && < 0.7, mtl >= 2.2.2 && < 2.4,