From e1bb9d5fa7039e774af5c3ac2c964684fc7747ee Mon Sep 17 00:00:00 2001 From: John Ky Date: Mon, 8 Jan 2024 11:00:10 +1100 Subject: [PATCH] Update CI --- .github/workflows/haskell.yml | 22 ++++++++++++-------- hw-mquery.cabal | 8 ++++---- src/HaskellWorks/Data/MQuery.hs | 2 +- src/HaskellWorks/Data/MQuery/Entry.hs | 6 ++++-- src/HaskellWorks/Data/MQuery/Micro.hs | 29 +++++++++++++++------------ src/HaskellWorks/Data/MQuery/Mini.hs | 11 +++++----- src/HaskellWorks/Data/MQuery/Row.hs | 18 +++++++++-------- 7 files changed, 55 insertions(+), 41 deletions(-) diff --git a/.github/workflows/haskell.yml b/.github/workflows/haskell.yml index fda15c7..e65a47d 100644 --- a/.github/workflows/haskell.yml +++ b/.github/workflows/haskell.yml @@ -17,27 +17,33 @@ jobs: strategy: fail-fast: false matrix: - ghc: ["9.4.2", "9.2.4", "9.0.2", "8.10.7", "8.8.4", "8.6.5"] + ghc: ["9.8.1", "9.6.3", "9.4.8", "9.2.8", "9.0.2", "8.10.7"] os: [ubuntu-latest, macOS-latest, windows-latest] exclude: - - ghc: "9.4.2" - os: windows-latest + - os: windows-latest + ghc: "9.4.2" + + env: + # Modify this value to "invalidate" the cabal cache. + CABAL_CACHE_VERSION: "2024-01-05" steps: - uses: actions/checkout@v2 - - uses: haskell/actions/setup@v1 + - uses: haskell-actions/setup@v2 id: setup-haskell with: ghc-version: ${{ matrix.ghc }} - cabal-version: 3.6.2.0 + cabal-version: '3.10.2.1' - name: Set some window specific things if: matrix.os == 'windows-latest' run: echo 'EXE_EXT=.exe' >> $GITHUB_ENV - name: Configure project - run: cabal configure --enable-tests --enable-benchmarks --write-ghc-environment-files=ghc8.4.4+ + run: | + cabal configure --enable-tests --enable-benchmarks --write-ghc-environment-files=ghc8.4.4+ + cabal build all --enable-tests --enable-benchmarks --dry-run - name: Cabal cache over S3 uses: action-works/cabal-cache-s3@v1 @@ -49,7 +55,7 @@ jobs: dist-dir: dist-newstyle store-path: ${{ steps.setup-haskell.outputs.cabal-store }} threads: 16 - archive-uri: ${{ secrets.BINARY_CACHE_URI }} + archive-uri: ${{ secrets.BINARY_CACHE_URI }}/${{ env.CABAL_CACHE_VERSION }}/${{ runner.os }}/${{ matrix.cabal }}/${{ matrix.ghc }} skip: "${{ secrets.BINARY_CACHE_URI == '' }}" - name: Cabal cache over HTTPS @@ -58,7 +64,7 @@ jobs: dist-dir: dist-newstyle store-path: ${{ steps.setup-haskell.outputs.cabal-store }} threads: 16 - archive-uri: https://cache.haskellworks.io/archive + archive-uri: https://cache.haskellworks.io/${{ env.CABAL_CACHE_VERSION }}/${{ runner.os }}/${{ matrix.cabal }}/${{ matrix.ghc }} skip: "${{ secrets.BINARY_CACHE_URI != '' }}" - name: Build diff --git a/hw-mquery.cabal b/hw-mquery.cabal index 0a0a26c..d89c8bc 100644 --- a/hw-mquery.cabal +++ b/hw-mquery.cabal @@ -22,11 +22,11 @@ source-repository head common base { build-depends: base >= 4.11 && < 5 } -common ansi-wl-pprint { build-depends: ansi-wl-pprint >= 0.6.8 && < 0.7 } +common prettyprinter { build-depends: prettyprinter >= 1 && < 2 } common dlist { build-depends: dlist >= 0.8.0 && < 1.1 } -common doctest { build-depends: doctest >= 0.16.2 && < 0.21 } +common doctest { build-depends: doctest >= 0.16.2 && < 0.23 } common doctest-discover { build-depends: doctest-discover >= 0.2 && < 0.3 } -common hedgehog { build-depends: hedgehog >= 0.6.1 && < 1.3 } +common hedgehog { build-depends: hedgehog >= 0.6.1 && < 1.5 } common hspec { build-depends: hspec >= 2.6.0 && < 3 } common hw-hspec-hedgehog { build-depends: hw-hspec-hedgehog >= 0.1.0.5 && < 0.2 } common lens { build-depends: lens >= 4.17 && < 6 } @@ -40,7 +40,7 @@ common hw-mquery library import: base, config - , ansi-wl-pprint + , prettyprinter , dlist , lens hs-source-dirs: src diff --git a/src/HaskellWorks/Data/MQuery.hs b/src/HaskellWorks/Data/MQuery.hs index 90cc970..d6a844c 100644 --- a/src/HaskellWorks/Data/MQuery.hs +++ b/src/HaskellWorks/Data/MQuery.hs @@ -13,7 +13,7 @@ import GHC.Base import HaskellWorks.Data.MQuery.Entry import HaskellWorks.Data.MQuery.Row import HaskellWorks.Data.MQuery.ToBool -import Text.PrettyPrint.ANSI.Leijen hiding ((<>)) +import Prettyprinter import qualified Data.DList as DL diff --git a/src/HaskellWorks/Data/MQuery/Entry.hs b/src/HaskellWorks/Data/MQuery/Entry.hs index ce1bbd7..1b75e3c 100644 --- a/src/HaskellWorks/Data/MQuery/Entry.hs +++ b/src/HaskellWorks/Data/MQuery/Entry.hs @@ -1,8 +1,10 @@ +{-# LANGUAGE OverloadedStrings #-} + module HaskellWorks.Data.MQuery.Entry where -import Text.PrettyPrint.ANSI.Leijen +import Prettyprinter data Entry k v = Entry k v instance (Pretty k, Pretty v) => Pretty (Entry k v) where - pretty (Entry k v) = pretty k <> text ": " <> pretty v + pretty (Entry k v) = pretty k <> ": " <> pretty v diff --git a/src/HaskellWorks/Data/MQuery/Micro.hs b/src/HaskellWorks/Data/MQuery/Micro.hs index 51098ca..1691b0d 100644 --- a/src/HaskellWorks/Data/MQuery/Micro.hs +++ b/src/HaskellWorks/Data/MQuery/Micro.hs @@ -1,34 +1,37 @@ {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE ScopedTypeVariables #-} +{-# LANGUAGE OverloadedStrings #-} module HaskellWorks.Data.MQuery.Micro where -import Text.PrettyPrint.ANSI.Leijen +import Prettyprinter +import Prettyprinter.Render.Text + import qualified Data.DList as DL newtype Micro a = Micro a -prettyVs :: Pretty a => [a] -> Doc -prettyVs (kv:kvs) = pretty kv <> foldl (<>) empty ((\jv -> text ", " <> pretty jv) `map` kvs) -prettyVs [] = empty +prettyVs :: Pretty a => [a] -> Doc ann +prettyVs (kv:kvs) = pretty kv <> foldl (<>) mempty ((\jv -> ", " <> pretty jv) `map` kvs) +prettyVs [] = mempty putPretty :: Pretty a => a -> IO () putPretty a = putDoc (pretty a <> hardline) -prettyKvs :: Pretty (Micro a) => [a] -> Doc -prettyKvs (kv:kvs) = pretty (Micro kv) <> foldl (<>) empty ((\jv -> text ", " <> pretty (Micro jv)) `map` kvs) -prettyKvs [] = empty +prettyKvs :: Pretty (Micro a) => [a] -> Doc ann +prettyKvs (kv:kvs) = pretty (Micro kv) <> foldl (<>) mempty ((\jv -> ", " <> pretty (Micro jv)) `map` kvs) +prettyKvs [] = mempty instance Pretty a => Pretty (Micro [a]) where pretty (Micro xs) = case length xs of - xsLen | xsLen == 0 -> text "[]" - xsLen | xsLen <= 10 -> text "[" <> prettyVs xs <> text "]" - _ -> text "[" <> prettyVs (take 10 xs) <> text ", ..]" + xsLen | xsLen == 0 -> "[]" + xsLen | xsLen <= 10 -> "[" <> prettyVs xs <> "]" + _ -> "[" <> prettyVs (take 10 xs) <> ", ..]" instance Pretty a => Pretty (Micro (DL.DList a)) where pretty (Micro dxs) = case DL.toList dxs of - xs@(_:_:_:_:_:_:_:_:_:_:_:_:_) -> text "[" <> prettyVs (take 50 xs) <> text ", ..]" - [] -> text "[]" - xs -> text "[" <> prettyVs xs <> text "]" + xs@(_:_:_:_:_:_:_:_:_:_:_:_:_) -> "[" <> prettyVs (take 50 xs) <> ", ..]" + [] -> "[]" + xs -> "[" <> prettyVs xs <> "]" diff --git a/src/HaskellWorks/Data/MQuery/Mini.hs b/src/HaskellWorks/Data/MQuery/Mini.hs index 6a4dc5c..a11539f 100644 --- a/src/HaskellWorks/Data/MQuery/Mini.hs +++ b/src/HaskellWorks/Data/MQuery/Mini.hs @@ -1,20 +1,21 @@ {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE FlexibleInstances #-} +{-# LANGUAGE OverloadedStrings #-} module HaskellWorks.Data.MQuery.Mini where import HaskellWorks.Data.MQuery.AtLeastSize import HaskellWorks.Data.MQuery.Micro -import Text.PrettyPrint.ANSI.Leijen +import Prettyprinter import qualified Data.DList as DL newtype Mini a = Mini a instance Pretty (Micro a) => Pretty (Mini [a]) where - pretty (Mini xs) | xs `atLeastSize` 11 = text "[" <> nest 2 (prettyVs (take 10 (Micro `map` xs))) <> text ", ..]" - pretty (Mini xs) | xs `atLeastSize` 1 = text "[" <> nest 2 (prettyVs (take 10 (Micro `map` xs))) <> text "]" - pretty (Mini _ ) = text "[]" + pretty (Mini xs) | xs `atLeastSize` 11 = "[" <> nest 2 (prettyVs (take 10 (Micro `map` xs))) <> ", ..]" + pretty (Mini xs) | xs `atLeastSize` 1 = "[" <> nest 2 (prettyVs (take 10 (Micro `map` xs))) <> "]" + pretty (Mini _ ) = "[]" instance Pretty (Mini a) => Pretty (Mini (DL.DList a)) where - pretty (Mini xs) = vcat (punctuate (text ",") ((pretty . Mini) `map` take 10 (DL.toList xs))) + pretty (Mini xs) = vcat (punctuate "," ((pretty . Mini) `map` take 10 (DL.toList xs))) diff --git a/src/HaskellWorks/Data/MQuery/Row.hs b/src/HaskellWorks/Data/MQuery/Row.hs index d835f7f..260908f 100644 --- a/src/HaskellWorks/Data/MQuery/Row.hs +++ b/src/HaskellWorks/Data/MQuery/Row.hs @@ -1,9 +1,10 @@ {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE FlexibleInstances #-} +{-# LANGUAGE OverloadedStrings #-} module HaskellWorks.Data.MQuery.Row where -import Text.PrettyPrint.ANSI.Leijen +import Prettyprinter import qualified Data.DList as DL @@ -12,11 +13,12 @@ type MaxChars = Int data Row a = Row MaxChars a instance Pretty a => Pretty (Row (DL.DList a)) where - pretty (Row maxChars xs) = vcat (((bold . yellow) (text "==> ") <>) `map` prettyRows) - where prettyRows :: [Doc] - prettyRows = (\row -> text (take maxChars (displayS (renderCompact (pretty row)) []))) `map` DL.toList xs + -- TODO implement max chars for Row + pretty (Row _ xs) = vcat (("==> " <>) `map` prettyRows) + where prettyRows :: [Doc ann] + prettyRows = fmap pretty $ DL.toList xs -prettyRowOfString :: Show a => Row (DL.DList a) -> Doc -prettyRowOfString (Row _ xs) = vcat (((bold . yellow) (text "==> ") <>) `map` prettyRows) - where prettyRows :: [Doc] - prettyRows = (text . show) `map` DL.toList xs +prettyRowOfString :: Show a => Row (DL.DList a) -> Doc ann +prettyRowOfString (Row _ xs) = vcat (("==> " <>) `map` prettyRows) + where prettyRows :: [Doc ann] + prettyRows = (pretty . show) `map` DL.toList xs