Skip to content

Commit

Permalink
Merge pull request #59 from haskell-works/newhoggy/update-ci
Browse files Browse the repository at this point in the history
Update CI
  • Loading branch information
newhoggy authored Jan 8, 2024
2 parents 08503cd + e1bb9d5 commit 4d4f0ec
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 41 deletions.
22 changes: 14 additions & 8 deletions .github/workflows/haskell.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
8 changes: 4 additions & 4 deletions hw-mquery.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand All @@ -40,7 +40,7 @@ common hw-mquery

library
import: base, config
, ansi-wl-pprint
, prettyprinter
, dlist
, lens
hs-source-dirs: src
Expand Down
2 changes: 1 addition & 1 deletion src/HaskellWorks/Data/MQuery.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 4 additions & 2 deletions src/HaskellWorks/Data/MQuery/Entry.hs
Original file line number Diff line number Diff line change
@@ -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
29 changes: 16 additions & 13 deletions src/HaskellWorks/Data/MQuery/Micro.hs
Original file line number Diff line number Diff line change
@@ -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 <> "]"
11 changes: 6 additions & 5 deletions src/HaskellWorks/Data/MQuery/Mini.hs
Original file line number Diff line number Diff line change
@@ -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)))
18 changes: 10 additions & 8 deletions src/HaskellWorks/Data/MQuery/Row.hs
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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

0 comments on commit 4d4f0ec

Please sign in to comment.