From 24ebd308c017294359eeabb128701eae89599ccc Mon Sep 17 00:00:00 2001 From: patrick brisbin Date: Tue, 28 May 2024 07:55:26 -0400 Subject: [PATCH 1/9] Rev stack.yamls --- .github/workflows/ci.yml | 7 +++++-- stack-lts-19.33.yaml | 1 + stack-lts-19.33.yaml.lock | 12 ++++++++++++ stack-lts-20.26.yaml | 1 + stack-lts-20.26.yaml.lock | 12 ++++++++++++ stack-lts-21.25.yaml | 1 + stack-lts-21.25.yaml.lock | 12 ++++++++++++ stack-nightly.yaml | 2 +- stack-nightly.yaml.lock | 8 ++++---- stack.yaml | 6 +----- stack.yaml.lock | 17 +++++------------ 11 files changed, 55 insertions(+), 24 deletions(-) create mode 100644 stack-lts-19.33.yaml create mode 100644 stack-lts-19.33.yaml.lock create mode 100644 stack-lts-20.26.yaml create mode 100644 stack-lts-20.26.yaml.lock create mode 100644 stack-lts-21.25.yaml create mode 100644 stack-lts-21.25.yaml.lock diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 58b08c8..ea256dc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,8 +12,11 @@ jobs: strategy: matrix: stack-yaml: - - stack-nightly.yaml # ghc-9.2 - - stack.yaml # ghc-9.0 + - stack-nightly.yaml # ghc-9.8 + - stack.yaml # ghc-9.6 + - stack-lts-21.25.yaml # ghc-9.4 + - stack-lts-20.26.yaml # ghc-9.2 + - stack-lts-19.33.yaml # ghc-9.0 - stack-lts-18.28.yaml # ghc-8.10 - stack-lts-16.31.yaml # ghc-8.8 - stack-lts-14.27.yaml # ghc-8.6 diff --git a/stack-lts-19.33.yaml b/stack-lts-19.33.yaml new file mode 100644 index 0000000..f9994e6 --- /dev/null +++ b/stack-lts-19.33.yaml @@ -0,0 +1 @@ +resolver: lts-19.33 diff --git a/stack-lts-19.33.yaml.lock b/stack-lts-19.33.yaml.lock new file mode 100644 index 0000000..d79c369 --- /dev/null +++ b/stack-lts-19.33.yaml.lock @@ -0,0 +1,12 @@ +# This file was autogenerated by Stack. +# You should not edit this file by hand. +# For more information, please see the documentation at: +# https://docs.haskellstack.org/en/stable/lock_files + +packages: [] +snapshots: +- completed: + sha256: 6d1532d40621957a25bad5195bfca7938e8a06d923c91bc52aa0f3c41181f2d4 + size: 619204 + url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/19/33.yaml + original: lts-19.33 diff --git a/stack-lts-20.26.yaml b/stack-lts-20.26.yaml new file mode 100644 index 0000000..fc9172f --- /dev/null +++ b/stack-lts-20.26.yaml @@ -0,0 +1 @@ +resolver: lts-20.26 diff --git a/stack-lts-20.26.yaml.lock b/stack-lts-20.26.yaml.lock new file mode 100644 index 0000000..ea5a850 --- /dev/null +++ b/stack-lts-20.26.yaml.lock @@ -0,0 +1,12 @@ +# This file was autogenerated by Stack. +# You should not edit this file by hand. +# For more information, please see the documentation at: +# https://docs.haskellstack.org/en/stable/lock_files + +packages: [] +snapshots: +- completed: + sha256: 5a59b2a405b3aba3c00188453be172b85893cab8ebc352b1ef58b0eae5d248a2 + size: 650475 + url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/20/26.yaml + original: lts-20.26 diff --git a/stack-lts-21.25.yaml b/stack-lts-21.25.yaml new file mode 100644 index 0000000..377040a --- /dev/null +++ b/stack-lts-21.25.yaml @@ -0,0 +1 @@ +resolver: lts-21.25 diff --git a/stack-lts-21.25.yaml.lock b/stack-lts-21.25.yaml.lock new file mode 100644 index 0000000..f823d29 --- /dev/null +++ b/stack-lts-21.25.yaml.lock @@ -0,0 +1,12 @@ +# This file was autogenerated by Stack. +# You should not edit this file by hand. +# For more information, please see the documentation at: +# https://docs.haskellstack.org/en/stable/lock_files + +packages: [] +snapshots: +- completed: + sha256: a81fb3877c4f9031e1325eb3935122e608d80715dc16b586eb11ddbff8671ecd + size: 640086 + url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/21/25.yaml + original: lts-21.25 diff --git a/stack-nightly.yaml b/stack-nightly.yaml index 9eb59bb..d54ef25 100644 --- a/stack-nightly.yaml +++ b/stack-nightly.yaml @@ -1 +1 @@ -resolver: nightly-2022-03-30 +resolver: nightly-2024-05-28 diff --git a/stack-nightly.yaml.lock b/stack-nightly.yaml.lock index 0ed608e..84722f6 100644 --- a/stack-nightly.yaml.lock +++ b/stack-nightly.yaml.lock @@ -6,7 +6,7 @@ packages: [] snapshots: - completed: - size: 539378 - url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/nightly/2022/3/30.yaml - sha256: 745431a4c5b78cc93d81e99b2253a1e0eacd4f94e00cf17dab7cc14e665332e3 - original: nightly-2022-03-30 + sha256: 95b923f4f2efe2b6ba05c93ded367dfab81c545c0700731e5bef70bab03d9903 + size: 644344 + url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/nightly/2024/5/28.yaml + original: nightly-2024-05-28 diff --git a/stack.yaml b/stack.yaml index a03ff25..b4b7d3a 100644 --- a/stack.yaml +++ b/stack.yaml @@ -1,8 +1,4 @@ -resolver: lts-19.1 - -extra-deps: - # For weeder - - algebraic-graphs-0.5 +resolver: lts-22.23 flags: yesod-paginator: diff --git a/stack.yaml.lock b/stack.yaml.lock index f90d44d..b758c75 100644 --- a/stack.yaml.lock +++ b/stack.yaml.lock @@ -3,17 +3,10 @@ # For more information, please see the documentation at: # https://docs.haskellstack.org/en/stable/lock_files -packages: -- completed: - hackage: algebraic-graphs-0.5@sha256:6eeec5ed1687ff7aa916e7bf9f02f51aaabde6f314dc0b7b1a84156974d7da73,8071 - pantry-tree: - sha256: cca4a0348bb126506cacd8436948a68aad62e75d45df8c71f4090a00e69b45ee - size: 4128 - original: - hackage: algebraic-graphs-0.5 +packages: [] snapshots: - completed: - sha256: cbd5e8593869445794924668479b5bd9f1738d075898623dceacc13b2576b6e3 - size: 617355 - url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/19/1.yaml - original: lts-19.1 + sha256: 73ad581de7c5306278aec7706cafaf3b1c2eb7abf4ab586e4d9dc675c6106c4e + size: 718708 + url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/22/23.yaml + original: lts-22.23 From dc19199c84f6498264e2b5a54609d4be3b5cf588 Mon Sep 17 00:00:00 2001 From: patrick brisbin Date: Tue, 28 May 2024 07:57:37 -0400 Subject: [PATCH 2/9] Update actions --- .github/workflows/ci.yml | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ea256dc..5451f40 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -24,42 +24,35 @@ jobs: fail-fast: false steps: - - uses: actions/checkout@v2 - - uses: freckle/stack-cache-action@v1 - with: - stack-yaml: ${{ matrix.stack-yaml }} + - uses: actions/checkout@v4 - id: stack - uses: freckle/stack-action@v3 + uses: freckle/stack-action@v5 with: stack-yaml: ${{ matrix.stack-yaml }} stack-arguments: --coverage + compiler-tools: hpc-lcov - if: ${{ matrix.stack-yaml == 'stack.yaml' }} name: Reformat coverage - run: | - tix='${{ steps.stack.outputs.local-hpc-root }}/combined/all/all.tix' - stack --resolver lts-18.28 --no-terminal install --copy-compiler-tool hpc-lcov - stack --resolver lts-18.28 --no-terminal exec -- hpc-lcov --file "$tix" + run: stack exec -- hpc-lcov --file '${{ steps.stack.outputs.local-hpc-root }}/combined/all/all.tix' - if: ${{ matrix.stack-yaml == 'stack.yaml' }} name: Upload coverage - uses: codecov/codecov-action@v2 + uses: codecov/codecov-action@v4 with: files: ./lcov.info - if: ${{ matrix.stack-yaml == 'stack.yaml' }} - uses: freckle/weeder-action@v1 + uses: freckle/weeder-action@v2 with: - weeder-version: 2.3.0 + ghc-version: ${{ steps.stack.outputs.compiler-version }} hlint: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - uses: rwe/actions-hlint-setup@v1 - - run: | - curl -o .hlint.yaml https://raw.githubusercontent.com/pbrisbin/dotfiles/master/hlint.yaml - - uses: rwe/actions-hlint-run@v2 + - uses: actions/checkout@v4 + - uses: haskell-actions/hlint-setup@v2 + - uses: haskell-actions/hlint-run@v2 with: fail-on: warning From 4fb6ae614f800768300336d9bdd53099b8b6245c Mon Sep 17 00:00:00 2001 From: patrick brisbin Date: Tue, 28 May 2024 08:21:48 -0400 Subject: [PATCH 3/9] Add weeder.toml --- weeder.toml | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 weeder.toml diff --git a/weeder.toml b/weeder.toml new file mode 100644 index 0000000..f4c1e63 --- /dev/null +++ b/weeder.toml @@ -0,0 +1,2 @@ +roots = ["^Main\\.main$", "^Paths_.*"] +type-class-roots = true From a4e3fadda7d40720f61c429296924fa4e13c39c1 Mon Sep 17 00:00:00 2001 From: patrick brisbin Date: Tue, 28 May 2024 08:23:45 -0400 Subject: [PATCH 4/9] Use env.STACK_YAML --- .github/workflows/ci.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5451f40..28a2245 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,13 +23,15 @@ jobs: - stack-lts-12.26.yaml # ghc-8.4 fail-fast: false + env: + STACK_YAML: ${{ matrix.stack-yaml }} + steps: - uses: actions/checkout@v4 - id: stack uses: freckle/stack-action@v5 with: - stack-yaml: ${{ matrix.stack-yaml }} stack-arguments: --coverage compiler-tools: hpc-lcov From 07b1bfeb7661f9887831216e3af58ca3696e67fb Mon Sep 17 00:00:00 2001 From: patrick brisbin Date: Tue, 28 May 2024 08:24:29 -0400 Subject: [PATCH 5/9] Silence role-annotation warning --- package.yaml | 3 +++ yesod-paginator.cabal | 10 +++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/package.yaml b/package.yaml index e39fa4e..db4cdbd 100644 --- a/package.yaml +++ b/package.yaml @@ -18,6 +18,9 @@ ghc-options: - -Wno-unsafe when: + - condition: impl(ghc >= 9.8) + ghc-options: + - -Wno-missing-role-annotations - condition: impl(ghc >= 9.2) ghc-options: - -Wno-missing-kind-signatures diff --git a/yesod-paginator.cabal b/yesod-paginator.cabal index b1ebded..b9e1bcf 100644 --- a/yesod-paginator.cabal +++ b/yesod-paginator.cabal @@ -1,6 +1,6 @@ cabal-version: 1.12 --- This file has been generated from package.yaml by hpack version 0.35.0. +-- This file has been generated from package.yaml by hpack version 0.36.0. -- -- see: https://github.com/sol/hpack @@ -47,6 +47,8 @@ library , uri-encode , yesod-core default-language: Haskell2010 + if impl(ghc >= 9.8) + ghc-options: -Wno-missing-role-annotations if impl(ghc >= 9.2) ghc-options: -Wno-missing-kind-signatures if impl(ghc >= 8.10) @@ -69,6 +71,8 @@ executable yesod-paginator-example , yesod , yesod-paginator default-language: Haskell2010 + if impl(ghc >= 9.8) + ghc-options: -Wno-missing-role-annotations if impl(ghc >= 9.2) ghc-options: -Wno-missing-kind-signatures if impl(ghc >= 8.10) @@ -92,6 +96,8 @@ test-suite doctests base <5 , doctest default-language: Haskell2010 + if impl(ghc >= 9.8) + ghc-options: -Wno-missing-role-annotations if impl(ghc >= 9.2) ghc-options: -Wno-missing-kind-signatures if impl(ghc >= 8.10) @@ -121,6 +127,8 @@ test-suite test , yesod-paginator , yesod-test default-language: Haskell2010 + if impl(ghc >= 9.8) + ghc-options: -Wno-missing-role-annotations if impl(ghc >= 9.2) ghc-options: -Wno-missing-kind-signatures if impl(ghc >= 8.10) From 32a81ff596581e2ebbaeffb75ea60bbc04f10326 Mon Sep 17 00:00:00 2001 From: patrick brisbin Date: Tue, 28 May 2024 08:25:44 -0400 Subject: [PATCH 6/9] Stop running weeder on a library --- .github/workflows/ci.yml | 5 ----- weeder.toml | 2 -- 2 files changed, 7 deletions(-) delete mode 100644 weeder.toml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 28a2245..40578fc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -45,11 +45,6 @@ jobs: with: files: ./lcov.info - - if: ${{ matrix.stack-yaml == 'stack.yaml' }} - uses: freckle/weeder-action@v2 - with: - ghc-version: ${{ steps.stack.outputs.compiler-version }} - hlint: runs-on: ubuntu-latest steps: diff --git a/weeder.toml b/weeder.toml deleted file mode 100644 index f4c1e63..0000000 --- a/weeder.toml +++ /dev/null @@ -1,2 +0,0 @@ -roots = ["^Main\\.main$", "^Paths_.*"] -type-class-roots = true From f74b72279cf089eeabdcc0ca9757545d3f08bc30 Mon Sep 17 00:00:00 2001 From: patrick brisbin Date: Tue, 28 May 2024 08:25:59 -0400 Subject: [PATCH 7/9] Remove Makefile --- Makefile | 42 ------------------------------------------ 1 file changed, 42 deletions(-) delete mode 100644 Makefile diff --git a/Makefile b/Makefile deleted file mode 100644 index 3b579a0..0000000 --- a/Makefile +++ /dev/null @@ -1,42 +0,0 @@ -all: setup build test lint - -.PHONY: setup -setup: - stack setup - stack build \ - --flag yesod-paginator:examples \ - --dependencies-only --test --no-run-tests - stack install hlint weeder - -.PHONY: build -build: - stack build \ - --flag yesod-paginator:examples \ - --pedantic --test --no-run-tests - -.PHONY: test -test: - stack build \ - --flag yesod-paginator:examples \ - --pedantic --test - - -.PHONY: lint -lint: - hlint . - weeder . - -.PHONY: clean -clean: - stack clean - -.PHONY: docs -docs: - stack --work-dir .stack-work-docs build --haddock - -.PHONY: check-nightly -check-nightly: - stack setup --resolver nightly - stack build --resolver nightly \ - --flag yesod-paginator:examples \ - --pedantic --test From 7f1a7dbd0b02377ed144f0b44afffbe4a05b17da Mon Sep 17 00:00:00 2001 From: patrick brisbin Date: Tue, 28 May 2024 08:31:39 -0400 Subject: [PATCH 8/9] Migrate to fourmolu --- .restyled.yaml | 13 +- .stylish-haskell.yaml | 23 -- Setup.hs | 1 + brittany.yaml | 40 --- doctest/Main.hs | 4 +- example/Main.hs | 27 +- fourmolu.yaml | 17 + src/Yesod/Paginator.hs | 40 ++- src/Yesod/Paginator/Pages.hs | 116 +++---- src/Yesod/Paginator/Paginate.hs | 131 ++++---- src/Yesod/Paginator/PaginationConfig.hs | 23 +- src/Yesod/Paginator/Prelude.hs | 23 +- src/Yesod/Paginator/Widgets.hs | 109 +++--- test/Spec.hs | 2 +- test/SpecHelper.hs | 50 +-- test/Yesod/Paginator/PagesSpec.hs | 58 ++-- test/Yesod/Paginator/WidgetsSpec.hs | 424 ++++++++++++------------ 17 files changed, 539 insertions(+), 562 deletions(-) delete mode 100644 .stylish-haskell.yaml delete mode 100644 brittany.yaml create mode 100644 fourmolu.yaml diff --git a/.restyled.yaml b/.restyled.yaml index 6d7f543..17f7012 100644 --- a/.restyled.yaml +++ b/.restyled.yaml @@ -1,12 +1,3 @@ ---- restylers: - - stylish-haskell: - include: - - "**/*.hs" - - "!src/Yesod/Paginator/Pages.hs" # avoid DerivingStrategies - - brittany: - include: - - "**/*.hs" - - "!src/Yesod/Paginator/Pages.hs" # avoid DerivingStrategies - - "!example/Main.hs" # HsSpliceE - - "!src/Yesod/Paginator/Widgets.hs" # HsSpliceE + - "!stylish-haskell" + - fourmolu diff --git a/.stylish-haskell.yaml b/.stylish-haskell.yaml deleted file mode 100644 index 37d34b8..0000000 --- a/.stylish-haskell.yaml +++ /dev/null @@ -1,23 +0,0 @@ ---- -steps: - - simple_align: - cases: false - top_level_patterns: false - records: false - - imports: - align: none - list_align: after_alias - pad_module_names: false - long_list_align: new_line_multiline - empty_list_align: right_after - list_padding: 4 - separate_lists: false - space_surround: false - - language_pragmas: - style: vertical - align: false - # https://github.com/jaspervdj/stylish-haskell/issues/75 - remove_redundant: false - - trailing_whitespace: {} -columns: 80 -newline: native diff --git a/Setup.hs b/Setup.hs index 9a994af..e8ef27d 100644 --- a/Setup.hs +++ b/Setup.hs @@ -1,2 +1,3 @@ import Distribution.Simple + main = defaultMain diff --git a/brittany.yaml b/brittany.yaml deleted file mode 100644 index d24180f..0000000 --- a/brittany.yaml +++ /dev/null @@ -1,40 +0,0 @@ ---- -conf_debug: - dconf_roundtrip_exactprint_only: false - dconf_dump_bridoc_simpl_par: false - dconf_dump_ast_unknown: false - dconf_dump_bridoc_simpl_floating: false - dconf_dump_config: false - dconf_dump_bridoc_raw: false - dconf_dump_bridoc_final: false - dconf_dump_bridoc_simpl_alt: false - dconf_dump_bridoc_simpl_indent: false - dconf_dump_annotations: false - dconf_dump_bridoc_simpl_columns: false - dconf_dump_ast_full: false -conf_forward: - options_ghc: [] -conf_errorHandling: - econf_ExactPrintFallback: ExactPrintFallbackModeInline - econf_Werror: false - econf_omit_output_valid_check: false - econf_produceOutputOnErrors: false -conf_preprocessor: - ppconf_CPPMode: CPPModeAbort - ppconf_hackAroundIncludes: false -conf_version: 1 -conf_layout: - lconfig_altChooser: - tag: AltChooserBoundedSearch - contents: 3 - lconfig_importColumn: 60 - lconfig_alignmentLimit: 1 - lconfig_indentListSpecial: true - lconfig_indentAmount: 4 - lconfig_alignmentBreakOnMultiline: true - lconfig_cols: 80 - lconfig_indentPolicy: IndentPolicyLeft - lconfig_indentWhereSpecial: true - lconfig_columnAlignMode: - tag: ColumnAlignModeDisabled - contents: 0.7 \ No newline at end of file diff --git a/doctest/Main.hs b/doctest/Main.hs index 2d5ea2c..8e78415 100644 --- a/doctest/Main.hs +++ b/doctest/Main.hs @@ -1,6 +1,6 @@ module Main - ( main - ) where + ( main + ) where import Prelude diff --git a/example/Main.hs b/example/Main.hs index cd16258..73e853d 100644 --- a/example/Main.hs +++ b/example/Main.hs @@ -8,8 +8,8 @@ {-# OPTIONS_GHC -Wno-unused-top-binds #-} module Main - ( main - ) where + ( main + ) where import Prelude @@ -19,15 +19,18 @@ import Yesod.Paginator data App = App -mkYesod "App" [parseRoutes| +mkYesod + "App" + [parseRoutes| / RootR GET |] instance Yesod App where - approot = ApprootRelative - defaultLayout widget = do - pc <- widgetToPageContent widget - withUrlRenderer [hamlet|$newline never + approot = ApprootRelative + defaultLayout widget = do + pc <- widgetToPageContent widget + withUrlRenderer + [hamlet|$newline never $doctype 5 @@ -43,13 +46,13 @@ instance Yesod App where getRootR :: Handler Html getRootR = do - let things' = [1 .. 1142] :: [Int] + let things' = [1 .. 1142] :: [Int] - pages <- paginate 3 things' + pages <- paginate 3 things' - defaultLayout $ do - setTitle "My title" - [whamlet|$newline never + defaultLayout $ do + setTitle "My title" + [whamlet|$newline never

Pagination Examples

The things: