From 7f6e7c1b121863052f0b9dcd89660b854552ec4b Mon Sep 17 00:00:00 2001 From: webdevred <148627186+webdevred@users.noreply.github.com> Date: Tue, 11 Aug 2026 08:07:11 +0200 Subject: [PATCH 1/2] Make the containers 0.8 rule lookup a cabal flag containers 0.8 has filterKeys, which the rule lookup wants, but the stack snapshot ships 0.7. The flag is on by default and stack.yaml turns it off, so neither build needs pinned extra-deps. --- .hlint.yaml | 2 +- jbeam-edit.cabal | 18 +++++++++++------- package.yaml | 6 +++++- src/JbeamEdit/Formatting/Rules.hs | 8 +++++++- stack.yaml | 1 + 5 files changed, 25 insertions(+), 10 deletions(-) diff --git a/.hlint.yaml b/.hlint.yaml index 6d4bcb46..d4ccbd97 100644 --- a/.hlint.yaml +++ b/.hlint.yaml @@ -1,7 +1,7 @@ - extensions: - default: true - {name: LambdaCase, within: []} - - {name: CPP, within: [JbeamEdit.Formatting, JbeamEdit.Formatting.Config]} + - {name: CPP, within: [JbeamEdit.Formatting, JbeamEdit.Formatting.Config, JbeamEdit.Formatting.Rules]} - modules: - {name: '**', qualifiedStyle: post} - warn: {lhs: nub (sort x), rhs: Data.List.Extra.nubSort x} diff --git a/jbeam-edit.cabal b/jbeam-edit.cabal index f3e0b62c..6a0b857d 100644 --- a/jbeam-edit.cabal +++ b/jbeam-edit.cabal @@ -49,6 +49,10 @@ flag dump-ast default: False manual: True +flag modern-containers + description: Require containers 0.8 + manual: True + flag transformation description: Enable transformation (experimental) default: False @@ -107,7 +111,7 @@ library text >=2.1.2, vector >=0.13 - if (!flag(transformation) && !flag(dump-ast)) + if flag(modern-containers) build-depends: containers >=0.8 if os(windows) @@ -154,7 +158,7 @@ library jbeam-edit-transformation text >=2.1.2, vector >=0.13 - if (!flag(transformation) && !flag(dump-ast)) + if flag(modern-containers) build-depends: containers >=0.8 if os(windows) @@ -202,7 +206,7 @@ executable jbeam-edit text >=2.1.2, vector >=0.13 - if (!flag(transformation) && !flag(dump-ast)) + if flag(modern-containers) build-depends: containers >=0.8 if os(windows) @@ -240,7 +244,7 @@ executable jbeam-edit-dump-ast text >=2.1.2, vector >=0.13 - if (!flag(transformation) && !flag(dump-ast)) + if flag(modern-containers) build-depends: containers >=0.8 if os(windows) @@ -296,7 +300,7 @@ test-suite jbeam-edit-test text >=2.1.2, vector >=0.13 - if (!flag(transformation) && !flag(dump-ast)) + if flag(modern-containers) build-depends: containers >=0.8 if os(windows) @@ -341,7 +345,7 @@ test-suite jbeam-edit-transformation-test text >=2.1.2, vector >=0.13 - if (!flag(transformation) && !flag(dump-ast)) + if flag(modern-containers) build-depends: containers >=0.8 if os(windows) @@ -385,7 +389,7 @@ benchmark jbeam-edit-bench text >=2.1.2, vector >=0.13 - if (!flag(transformation) && !flag(dump-ast)) + if flag(modern-containers) build-depends: containers >=0.8 if os(windows) diff --git a/package.yaml b/package.yaml index 04f0a267..0114c952 100644 --- a/package.yaml +++ b/package.yaml @@ -56,7 +56,7 @@ ghc-options: - -Wredundant-constraints when: - - condition: '! flag(transformation) && ! flag(dump-ast)' + - condition: flag(modern-containers) dependencies: [containers >= 0.8] - condition: os(windows) ghc-options: -optc-Os -optl-static @@ -74,6 +74,10 @@ flags: description: Use executable-relative example paths (for Windows release builds) default: false manual: true + modern-containers: + description: Require containers 0.8 + manual: true + default: true internal-libraries: jbeam-edit-transformation: diff --git a/src/JbeamEdit/Formatting/Rules.hs b/src/JbeamEdit/Formatting/Rules.hs index 59f68477..a86ecf7d 100644 --- a/src/JbeamEdit/Formatting/Rules.hs +++ b/src/JbeamEdit/Formatting/Rules.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE CPP #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE GADTs #-} {-# LANGUAGE RankNTypes #-} @@ -283,7 +284,12 @@ sameBy matchMode f = go in res && go ps bs go ps bs = Seq.null ps && (Seq.null bs || PrefixMatch == matchMode) --- TODO: when possible upgrade to containers 0.8 and migrate to M.filterKeys +#if MIN_VERSION_containers(0, 8, 0) +findPropertiesForCursor :: MatchMode -> NC.NodeCursor -> RuleSet -> Rule +findPropertiesForCursor matchMode cursor (RuleSet rs) = + fold (M.filterKeys (compareCursorAndPattern matchMode cursor) rs) +#else findPropertiesForCursor :: MatchMode -> NC.NodeCursor -> RuleSet -> Rule findPropertiesForCursor matchMode cursor (RuleSet rs) = fold (M.filterWithKey (const . compareCursorAndPattern matchMode cursor) rs) +#endif diff --git a/stack.yaml b/stack.yaml index 28c1ca11..6a63b046 100644 --- a/stack.yaml +++ b/stack.yaml @@ -6,6 +6,7 @@ flags: transformation: false dump-ast: false windows-example-paths: false + modern-containers: false ghc-options: jbeam-edit: "-Werror -Wwarn=unused-imports" From cbd59024d5e267c0b8cdf5416132748e0e6bd697 Mon Sep 17 00:00:00 2001 From: webdevred <148627186+webdevred@users.noreply.github.com> Date: Thu, 20 Aug 2026 19:15:20 +0200 Subject: [PATCH 2/2] Keep the rule lookup on the containers 0.7 API Nothing needs a function that only containers 0.8 has, so the lookup stays on filterWithKey and the CPP branch goes away. The release index-state moves forward because the ordered-containers revision that allows containers 0.8 is newer than the old pin, and the experimental release build could not resolve without it. --- .hlint.yaml | 2 +- cabal.project.release | 2 +- src/JbeamEdit/Formatting/Rules.hs | 8 +------- 3 files changed, 3 insertions(+), 9 deletions(-) diff --git a/.hlint.yaml b/.hlint.yaml index d4ccbd97..6d4bcb46 100644 --- a/.hlint.yaml +++ b/.hlint.yaml @@ -1,7 +1,7 @@ - extensions: - default: true - {name: LambdaCase, within: []} - - {name: CPP, within: [JbeamEdit.Formatting, JbeamEdit.Formatting.Config, JbeamEdit.Formatting.Rules]} + - {name: CPP, within: [JbeamEdit.Formatting, JbeamEdit.Formatting.Config]} - modules: - {name: '**', qualifiedStyle: post} - warn: {lhs: nub (sort x), rhs: Data.List.Extra.nubSort x} diff --git a/cabal.project.release b/cabal.project.release index f0118629..65bc1fe2 100644 --- a/cabal.project.release +++ b/cabal.project.release @@ -1,7 +1,7 @@ import: cabal.project executable-static: True executable-stripping: True -index-state: hackage.haskell.org 2026-06-15T00:00:00Z +index-state: hackage.haskell.org 2026-08-20T00:00:00Z package * ghc-options: diff --git a/src/JbeamEdit/Formatting/Rules.hs b/src/JbeamEdit/Formatting/Rules.hs index a86ecf7d..cede8c5e 100644 --- a/src/JbeamEdit/Formatting/Rules.hs +++ b/src/JbeamEdit/Formatting/Rules.hs @@ -1,4 +1,3 @@ -{-# LANGUAGE CPP #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE GADTs #-} {-# LANGUAGE RankNTypes #-} @@ -284,12 +283,7 @@ sameBy matchMode f = go in res && go ps bs go ps bs = Seq.null ps && (Seq.null bs || PrefixMatch == matchMode) -#if MIN_VERSION_containers(0, 8, 0) -findPropertiesForCursor :: MatchMode -> NC.NodeCursor -> RuleSet -> Rule -findPropertiesForCursor matchMode cursor (RuleSet rs) = - fold (M.filterKeys (compareCursorAndPattern matchMode cursor) rs) -#else +-- TODO: migrate to M.filterKeys once the stack snapshot ships containers 0.8 findPropertiesForCursor :: MatchMode -> NC.NodeCursor -> RuleSet -> Rule findPropertiesForCursor matchMode cursor (RuleSet rs) = fold (M.filterWithKey (const . compareCursorAndPattern matchMode cursor) rs) -#endif