From 3e56f602cc332e1d1172149a64e61cc88a615fac Mon Sep 17 00:00:00 2001 From: Javier Sagredo Date: Tue, 16 Jan 2024 14:59:03 +0100 Subject: [PATCH] Update QSM, remove Sing and Dict --- .hlint.yaml | 5 + cabal.project | 10 +- flake.lock | 6 +- .../ouroboros-consensus-cardano.cabal | 3 + .../Test/Consensus/Byron/Serialisation.hs | 2 +- .../Test/Consensus/Cardano/Serialisation.hs | 2 +- .../Test/Consensus/Shelley/Serialisation.hs | 2 +- .../ouroboros-consensus-diffusion.cabal | 1 + .../test/mock-test/Test/ThreadNet/BFT.hs | 2 +- ouroboros-consensus/ouroboros-consensus.cabal | 6 +- .../Consensus/HardFork/Combinator/Lifting.hs | 2 +- .../Combinator/Protocol/LedgerView.hs | 2 +- .../Combinator/Serialisation/SerialiseDisk.hs | 2 +- .../Ouroboros/Consensus/Util.hs | 8 +- .../Ouroboros/Consensus/Util/Singletons.hs | 56 ------- .../Test/Util/Serialisation/Roundtrip.hs | 2 +- scripts/release/cabal-plan-diff.sh | 148 +++++++++--------- sop-extras/src/Data/SOP/Counting.hs | 2 +- sop-extras/src/Data/SOP/Index.hs | 2 +- 19 files changed, 101 insertions(+), 162 deletions(-) delete mode 100644 ouroboros-consensus/src/ouroboros-consensus/Ouroboros/Consensus/Util/Singletons.hs diff --git a/.hlint.yaml b/.hlint.yaml index ee2818ce66..b985a87880 100644 --- a/.hlint.yaml +++ b/.hlint.yaml @@ -4,7 +4,12 @@ , as: [CSC, CsClient, CSClient] , message: "Exports fields with very common names" } + - { name: Data.SOP.Dict + , importStyle: explicitOrQualified + , message: "Avoid confusion with Data.Constraint (Dict)" + } - ignore: {} - warn: {name: Ouroboros.Consensus.MiniProtocol.ChainSync.Client should be imported qualified or with an explicit import list} +- error: {name: Data.SOP.Dict should be imported qualified or with an explicit import list} diff --git a/cabal.project b/cabal.project index 67c07a5865..d0dd323faa 100644 --- a/cabal.project +++ b/cabal.project @@ -14,7 +14,7 @@ repository cardano-haskell-packages -- update either of these. index-state: -- Bump this if you need newer packages from Hackage - , hackage.haskell.org 2023-12-14T23:57:38Z + , hackage.haskell.org 2024-01-16T12:10:07Z -- Bump this if you need newer packages from CHaP , cardano-haskell-packages 2023-12-15T13:02:57Z @@ -31,11 +31,3 @@ tests: true benchmarks: true import: ./asserts.cabal - --- Remove once QSM 0.9 is released, see --- https://github.com/stevana/quickcheck-state-machine/pull/31 -source-repository-package - type: git - location: https://github.com/stevana/quickcheck-state-machine - tag: 8e2bfb2214c7af1dae728180f2092effea6fbeb7 - --sha256: sha256-SRcuyKs0Sz+GBsCKE16LSnH14p3q8ZLxkcVyfErvfPQ= diff --git a/flake.lock b/flake.lock index 32253a8fc3..f7fdd6e182 100644 --- a/flake.lock +++ b/flake.lock @@ -225,11 +225,11 @@ "hackageNix": { "flake": false, "locked": { - "lastModified": 1704154975, - "narHash": "sha256-hD3WePXz4TvPVAHKvXN1xn6yFyWWSTPJGa/B9WVfrMQ=", + "lastModified": 1705450998, + "narHash": "sha256-3MfI/48FOfwSvWzJW89lF/cU9HJIw8swmQZzrHO/44M=", "owner": "input-output-hk", "repo": "hackage.nix", - "rev": "ab6b0b7741bd85f4209eb6a9af54e148e440c419", + "rev": "de3d2b30f3f149f338e533b111b38b6d03090931", "type": "github" }, "original": { diff --git a/ouroboros-consensus-cardano/ouroboros-consensus-cardano.cabal b/ouroboros-consensus-cardano/ouroboros-consensus-cardano.cabal index 698d9c0932..0baaadb103 100644 --- a/ouroboros-consensus-cardano/ouroboros-consensus-cardano.cabal +++ b/ouroboros-consensus-cardano/ouroboros-consensus-cardano.cabal @@ -247,6 +247,7 @@ test-suite byron-test , cardano-ledger-byron , cardano-ledger-byron-test , cborg + , constraints , containers , filepath , hedgehog-quickcheck @@ -328,6 +329,7 @@ test-suite shelley-test , cardano-protocol-tpraos , cardano-slotting , cborg + , constraints , containers , filepath , microlens @@ -420,6 +422,7 @@ test-suite cardano-test , cardano-protocol-tpraos , cardano-slotting , cborg + , constraints , containers , contra-tracer , filepath diff --git a/ouroboros-consensus-cardano/test/byron-test/Test/Consensus/Byron/Serialisation.hs b/ouroboros-consensus-cardano/test/byron-test/Test/Consensus/Byron/Serialisation.hs index 3e11194508..4ef5f093ec 100644 --- a/ouroboros-consensus-cardano/test/byron-test/Test/Consensus/Byron/Serialisation.hs +++ b/ouroboros-consensus-cardano/test/byron-test/Test/Consensus/Byron/Serialisation.hs @@ -18,6 +18,7 @@ import qualified Cardano.Chain.Block as CC.Block import qualified Cardano.Chain.Update as CC.Update import Codec.CBOR.Write (toLazyByteString) import qualified Data.ByteString.Lazy as Lazy +import Data.Constraint import Ouroboros.Consensus.Byron.Ledger import Ouroboros.Consensus.Byron.Node import Ouroboros.Consensus.Config @@ -25,7 +26,6 @@ import qualified Ouroboros.Consensus.Mempool as Mempool import Ouroboros.Consensus.Node.ProtocolInfo import Ouroboros.Consensus.Node.Serialisation () import Ouroboros.Consensus.Storage.Common (BinaryBlockInfo (..)) -import Ouroboros.Consensus.Util (Dict (..)) import qualified Test.Cardano.Chain.Genesis.Dummy as CC import Test.Consensus.Byron.Generators import Test.QuickCheck hiding (Result) diff --git a/ouroboros-consensus-cardano/test/cardano-test/Test/Consensus/Cardano/Serialisation.hs b/ouroboros-consensus-cardano/test/cardano-test/Test/Consensus/Cardano/Serialisation.hs index 6870e83995..272d429b55 100644 --- a/ouroboros-consensus-cardano/test/cardano-test/Test/Consensus/Cardano/Serialisation.hs +++ b/ouroboros-consensus-cardano/test/cardano-test/Test/Consensus/Cardano/Serialisation.hs @@ -8,6 +8,7 @@ module Test.Consensus.Cardano.Serialisation (tests) where import qualified Codec.CBOR.Write as CBOR import qualified Data.ByteString.Lazy as Lazy +import Data.Constraint import Ouroboros.Consensus.Block import Ouroboros.Consensus.Byron.Ledger import Ouroboros.Consensus.Byron.Node () @@ -17,7 +18,6 @@ import Ouroboros.Consensus.HardFork.Combinator.Block import Ouroboros.Consensus.Shelley.Ledger import Ouroboros.Consensus.Shelley.Node () import Ouroboros.Consensus.Storage.Serialisation -import Ouroboros.Consensus.Util (Dict (..)) import Ouroboros.Network.Block (Serialised (..)) import qualified Test.Consensus.Cardano.Examples as Cardano.Examples import Test.Consensus.Cardano.Generators (epochSlots) diff --git a/ouroboros-consensus-cardano/test/shelley-test/Test/Consensus/Shelley/Serialisation.hs b/ouroboros-consensus-cardano/test/shelley-test/Test/Consensus/Shelley/Serialisation.hs index ecb7e79bd7..4aa1540f68 100644 --- a/ouroboros-consensus-cardano/test/shelley-test/Test/Consensus/Shelley/Serialisation.hs +++ b/ouroboros-consensus-cardano/test/shelley-test/Test/Consensus/Shelley/Serialisation.hs @@ -8,6 +8,7 @@ module Test.Consensus.Shelley.Serialisation (tests) where import Cardano.Crypto.Hash (ShortHash) import qualified Codec.CBOR.Write as CBOR import qualified Data.ByteString.Lazy as Lazy +import Data.Constraint import Data.Proxy (Proxy (..)) import Data.Word (Word64) import Ouroboros.Consensus.Protocol.TPraos (TPraos) @@ -18,7 +19,6 @@ import Ouroboros.Consensus.Shelley.Node () import Ouroboros.Consensus.Shelley.Node.Serialisation () import Ouroboros.Consensus.Shelley.Protocol.TPraos () import Ouroboros.Consensus.Storage.Common (BinaryBlockInfo (..)) -import Ouroboros.Consensus.Util (Dict (..)) import Test.Consensus.Shelley.Generators () import Test.Consensus.Shelley.MockCrypto import Test.Tasty diff --git a/ouroboros-consensus-diffusion/ouroboros-consensus-diffusion.cabal b/ouroboros-consensus-diffusion/ouroboros-consensus-diffusion.cabal index 0a6d99de6b..50cbecd004 100644 --- a/ouroboros-consensus-diffusion/ouroboros-consensus-diffusion.cabal +++ b/ouroboros-consensus-diffusion/ouroboros-consensus-diffusion.cabal @@ -191,6 +191,7 @@ test-suite mock-test , base , bytestring , cborg + , constraints , containers , ouroboros-consensus:{ouroboros-consensus, unstable-consensus-testlib, unstable-mock-block} , ouroboros-network-mock diff --git a/ouroboros-consensus-diffusion/test/mock-test/Test/ThreadNet/BFT.hs b/ouroboros-consensus-diffusion/test/mock-test/Test/ThreadNet/BFT.hs index c07ce4b82d..e44eeced82 100644 --- a/ouroboros-consensus-diffusion/test/mock-test/Test/ThreadNet/BFT.hs +++ b/ouroboros-consensus-diffusion/test/mock-test/Test/ThreadNet/BFT.hs @@ -5,6 +5,7 @@ module Test.ThreadNet.BFT (tests) where +import Data.Constraint import Ouroboros.Consensus.Block import Ouroboros.Consensus.BlockchainTime import Ouroboros.Consensus.Config.SecurityParam @@ -13,7 +14,6 @@ import Ouroboros.Consensus.Mock.Ledger import Ouroboros.Consensus.Mock.Node () import Ouroboros.Consensus.Mock.Node.BFT import Ouroboros.Consensus.Mock.Node.Serialisation -import Ouroboros.Consensus.Util (Dict (..)) import Test.Consensus.Ledger.Mock.Generators () import Test.QuickCheck import Test.Tasty diff --git a/ouroboros-consensus/ouroboros-consensus.cabal b/ouroboros-consensus/ouroboros-consensus.cabal index ac7b5867cc..d23ae8c1f6 100644 --- a/ouroboros-consensus/ouroboros-consensus.cabal +++ b/ouroboros-consensus/ouroboros-consensus.cabal @@ -246,7 +246,6 @@ library Ouroboros.Consensus.Util.Orphans Ouroboros.Consensus.Util.RedundantConstraints Ouroboros.Consensus.Util.ResourceRegistry - Ouroboros.Consensus.Util.Singletons Ouroboros.Consensus.Util.STM Ouroboros.Consensus.Util.TentativeState Ouroboros.Consensus.Util.Time @@ -362,6 +361,7 @@ library unstable-consensus-testlib , cardano-prelude , cardano-strict-containers , cborg + , constraints , containers , contra-tracer , deepseq @@ -381,7 +381,7 @@ library unstable-consensus-testlib , ouroboros-network-mock , pretty-simple , QuickCheck - , quickcheck-state-machine:no-vendored-treediff ^>=0.8 + , quickcheck-state-machine:no-vendored-treediff ^>=0.9 , quiet , random , serialise @@ -625,7 +625,7 @@ test-suite storage-test , ouroboros-network-mock , pretty-show , QuickCheck - , quickcheck-state-machine:no-vendored-treediff ^>=0.8 + , quickcheck-state-machine:no-vendored-treediff ^>=0.9 , random , serialise , tasty diff --git a/ouroboros-consensus/src/ouroboros-consensus/Ouroboros/Consensus/HardFork/Combinator/Lifting.hs b/ouroboros-consensus/src/ouroboros-consensus/Ouroboros/Consensus/HardFork/Combinator/Lifting.hs index 3e5f451c5b..2b68138723 100644 --- a/ouroboros-consensus/src/ouroboros-consensus/Ouroboros/Consensus/HardFork/Combinator/Lifting.hs +++ b/ouroboros-consensus/src/ouroboros-consensus/Ouroboros/Consensus/HardFork/Combinator/Lifting.hs @@ -23,7 +23,7 @@ import Data.List (intercalate) import Data.Proxy import Data.SOP.BasicFunctors import Data.SOP.Constraint -import Data.SOP.Dict +import Data.SOP.Dict (Dict (..), all_NP, unAll_NP) import Data.SOP.Match (Mismatch) import Data.SOP.OptNP (OptNP (..)) import Data.SOP.Sing diff --git a/ouroboros-consensus/src/ouroboros-consensus/Ouroboros/Consensus/HardFork/Combinator/Protocol/LedgerView.hs b/ouroboros-consensus/src/ouroboros-consensus/Ouroboros/Consensus/HardFork/Combinator/Protocol/LedgerView.hs index 3c3a664958..81324783f2 100644 --- a/ouroboros-consensus/src/ouroboros-consensus/Ouroboros/Consensus/HardFork/Combinator/Protocol/LedgerView.hs +++ b/ouroboros-consensus/src/ouroboros-consensus/Ouroboros/Consensus/HardFork/Combinator/Protocol/LedgerView.hs @@ -17,7 +17,7 @@ module Ouroboros.Consensus.HardFork.Combinator.Protocol.LedgerView ( import Data.SOP.BasicFunctors import Data.SOP.Constraint -import Data.SOP.Dict +import Data.SOP.Dict (Dict (..), all_NP) import Data.SOP.Strict import Ouroboros.Consensus.HardFork.Combinator.Abstract import Ouroboros.Consensus.HardFork.Combinator.State.Instances () diff --git a/ouroboros-consensus/src/ouroboros-consensus/Ouroboros/Consensus/HardFork/Combinator/Serialisation/SerialiseDisk.hs b/ouroboros-consensus/src/ouroboros-consensus/Ouroboros/Consensus/HardFork/Combinator/Serialisation/SerialiseDisk.hs index 97b9378d29..ede3b7a4e6 100644 --- a/ouroboros-consensus/src/ouroboros-consensus/Ouroboros/Consensus/HardFork/Combinator/Serialisation/SerialiseDisk.hs +++ b/ouroboros-consensus/src/ouroboros-consensus/Ouroboros/Consensus/HardFork/Combinator/Serialisation/SerialiseDisk.hs @@ -10,7 +10,7 @@ import Codec.CBOR.Encoding (Encoding) import qualified Data.ByteString.Lazy as Lazy import Data.SOP.BasicFunctors import Data.SOP.Constraint -import Data.SOP.Dict +import Data.SOP.Dict (Dict (..), all_NP) import Data.SOP.Strict import Ouroboros.Consensus.Block import Ouroboros.Consensus.HardFork.Combinator.AcrossEras diff --git a/ouroboros-consensus/src/ouroboros-consensus/Ouroboros/Consensus/Util.hs b/ouroboros-consensus/src/ouroboros-consensus/Ouroboros/Consensus/Util.hs index ff8d68b979..f2d92326ce 100644 --- a/ouroboros-consensus/src/ouroboros-consensus/Ouroboros/Consensus/Util.hs +++ b/ouroboros-consensus/src/ouroboros-consensus/Ouroboros/Consensus/Util.hs @@ -10,8 +10,7 @@ -- | Miscellaneous utilities module Ouroboros.Consensus.Util ( -- * Type-level utility - Dict (..) - , Empty + Empty , ShowProxy (..) , Some (..) , SomePair (..) @@ -75,7 +74,7 @@ import Data.Foldable (asum, toList) import Data.Function (on) import Data.Functor.Identity import Data.Functor.Product -import Data.Kind (Constraint, Type) +import Data.Kind (Type) import Data.List (foldl', maximumBy) import Data.List.NonEmpty (NonEmpty (..), (<|)) import Data.Maybe (fromMaybe) @@ -90,9 +89,6 @@ import Ouroboros.Network.Util.ShowProxy (ShowProxy (..)) Type-level utility -------------------------------------------------------------------------------} -data Dict :: Constraint -> Type where - Dict :: a => Dict a - class Empty a instance Empty a diff --git a/ouroboros-consensus/src/ouroboros-consensus/Ouroboros/Consensus/Util/Singletons.hs b/ouroboros-consensus/src/ouroboros-consensus/Ouroboros/Consensus/Util/Singletons.hs deleted file mode 100644 index 53542ed5e2..0000000000 --- a/ouroboros-consensus/src/ouroboros-consensus/Ouroboros/Consensus/Util/Singletons.hs +++ /dev/null @@ -1,56 +0,0 @@ -{-# LANGUAGE DataKinds #-} -{-# LANGUAGE GADTs #-} -{-# LANGUAGE PolyKinds #-} -{-# LANGUAGE RankNTypes #-} -{-# LANGUAGE ScopedTypeVariables #-} -{-# LANGUAGE TypeApplications #-} -{-# LANGUAGE TypeFamilies #-} -{-# LANGUAGE TypeFamilyDependencies #-} -{-# LANGUAGE TypeOperators #-} - --- | Singletons --- --- This provides the core of the 'singletons' package, using the same name, --- but without pulling in all the dependencies and craziness. -module Ouroboros.Consensus.Util.Singletons ( - Sing (..) - , SingI (..) - , SingKind (..) - , SomeSing (..) - , withSomeSing - ) where - -import Data.Kind (Type) - --- | Data family of singletons -data family Sing (a :: k) - --- | Singletons for lists --- --- NOTE: Unlike the singletons library, we do /not/ require instances for the --- elements of the list. -data instance Sing (xs :: [k]) where - SNil :: Sing '[] - SCons :: Sing xs -> Sing (x ': xs) - -class SingI (a :: k) where - sing :: Sing a - -instance SingI '[] where sing = SNil -instance SingI xs => SingI (x ': xs) where sing = SCons sing - -data SomeSing k where - SomeSing :: Sing (a :: k) -> SomeSing k - -withSomeSing :: forall k r. SingKind k - => Demote k - -> (forall (a :: k). Sing a -> r) - -> r -withSomeSing d k = case toSing @k d :: SomeSing k of - SomeSing s -> k s - -class SingKind k where - type Demote k = (r :: Type) | r -> k - - fromSing :: Sing (a :: k) -> Demote k - toSing :: Demote k -> SomeSing k diff --git a/ouroboros-consensus/src/unstable-consensus-testlib/Test/Util/Serialisation/Roundtrip.hs b/ouroboros-consensus/src/unstable-consensus-testlib/Test/Util/Serialisation/Roundtrip.hs index 24eb3cdf70..d3ddb424c8 100644 --- a/ouroboros-consensus/src/unstable-consensus-testlib/Test/Util/Serialisation/Roundtrip.hs +++ b/ouroboros-consensus/src/unstable-consensus-testlib/Test/Util/Serialisation/Roundtrip.hs @@ -48,6 +48,7 @@ import qualified Data.ByteString.Base16.Lazy as Base16 import qualified Data.ByteString.Lazy as Lazy import qualified Data.ByteString.Lazy.Char8 as Char8 import qualified Data.ByteString.Short as Short +import Data.Constraint import Data.Function (on) import Data.Maybe (fromMaybe) import qualified Data.Text.Lazy as T @@ -72,7 +73,6 @@ import Ouroboros.Consensus.Node.Serialisation import Ouroboros.Consensus.Protocol.Abstract (ChainDepState) import Ouroboros.Consensus.Storage.ChainDB (SerialiseDiskConstraints) import Ouroboros.Consensus.Storage.Serialisation -import Ouroboros.Consensus.Util (Dict (..)) import Ouroboros.Network.Block (Serialised (..), fromSerialised, mkSerialised) import Quiet (Quiet (..)) diff --git a/scripts/release/cabal-plan-diff.sh b/scripts/release/cabal-plan-diff.sh index a856aab9d8..10b1a672d1 100755 --- a/scripts/release/cabal-plan-diff.sh +++ b/scripts/release/cabal-plan-diff.sh @@ -31,6 +31,7 @@ if [[ -d "./tmp" ]]; then rm -r tmp fi mkdir tmp +trap rm -r ./tmp EXIT cabal update &>/dev/null @@ -72,82 +73,79 @@ cabal build all --dry-run --minimize-conflict-set --project-file='./tmp/cabal.pr retVal=$? if [ $retVal -ne 0 ]; then - echo "error: Your project will fail to build in CHaP/Hackage" + echo "warning: Your project will fail to build in CHaP/Hackage" if [[ -n $GH ]]; then - echo "::error title=Unbuildable project::Your project will fail to build in CHaP/Hackage" + echo "::warning title=Unbuildable project::Your project will fail to build in CHaP/Hackage" fi - exit $retVal -fi - -cp ./dist-newstyle/cache/plan.json ./tmp/plan-libs.json - -cabal-plan diff --plan-json='tmp/plan-full.json' --plan-json='tmp/plan-libs.json' | awk "/Package versions/{f=1} /Dependency graph/{f=0} f" > ./tmp/the-diff-1 - -for i in "$@" ; do [[ $i == "--show-diff" ]] && cat ./tmp/the-diff-1 && break ; done - -awk '/^$/{f=!f} f' ./tmp/the-diff-1 > ./tmp/the-diff - -grep "^\-" ./tmp/the-diff | cut -d'-' -f2- | cut -d' ' -f1 > ./tmp/only-in-full -grep "^\+" ./tmp/the-diff | cut -d'+' -f2- | cut -d' ' -f1 > ./tmp/only-in-libs - -echo -e "\n=== TEST ONLY DEPENDENCIES" - -comm -2 -3 <(rev ./tmp/only-in-full | cut -d'-' -f2- | rev | uniq) <(rev ./tmp/only-in-libs | cut -d'-' -f2- | rev | uniq) - -echo -e "\n=== FULL-BUILD ONLY DEPENDENCIES" - -comm -1 -3 <(rev ./tmp/only-in-full | cut -d'-' -f2- | rev | uniq) <(rev ./tmp/only-in-libs | cut -d'-' -f2- | rev | uniq) - -echo -e "\n=== VERSION BUMPS FROM TESTS ONLY TO FULL-BUILD" - -common=$(comm -1 -2 <(rev ./tmp/only-in-full | cut -d'-' -f2- | rev | uniq) <(rev ./tmp/only-in-libs | cut -d'-' -f2- | rev | uniq)) - -major=() -minor=() -patch=() - -for dep in $common; do - full=$(grep -E "^$dep-([0-9]+\.)*[0-9]" ./tmp/only-in-full | rev | cut -d'-' -f1 | rev) - if [[ $(echo $full | awk -F. '{print NF-1}') -lt 3 ]]; then - n=$(((3 - $(echo $full | awk -F. '{print NF-1}'))*2)) - sff=".0.0.0.0" - full="$full${sff:0:$n}" +else + cp ./dist-newstyle/cache/plan.json ./tmp/plan-libs.json + + cabal-plan diff --plan-json='tmp/plan-full.json' --plan-json='tmp/plan-libs.json' | awk "/Package versions/{f=1} /Dependency graph/{f=0} f" > ./tmp/the-diff-1 + + for i in "$@" ; do [[ $i == "--show-diff" ]] && cat ./tmp/the-diff-1 && break ; done + + awk '/^$/{f=!f} f' ./tmp/the-diff-1 > ./tmp/the-diff + + grep "^\-" ./tmp/the-diff | cut -d'-' -f2- | cut -d' ' -f1 > ./tmp/only-in-full + grep "^\+" ./tmp/the-diff | cut -d'+' -f2- | cut -d' ' -f1 > ./tmp/only-in-libs + + echo -e "\n=== TEST ONLY DEPENDENCIES" + + comm -2 -3 <(rev ./tmp/only-in-full | cut -d'-' -f2- | rev | uniq) <(rev ./tmp/only-in-libs | cut -d'-' -f2- | rev | uniq) + + echo -e "\n=== FULL-BUILD ONLY DEPENDENCIES" + + comm -1 -3 <(rev ./tmp/only-in-full | cut -d'-' -f2- | rev | uniq) <(rev ./tmp/only-in-libs | cut -d'-' -f2- | rev | uniq) + + echo -e "\n=== VERSION BUMPS FROM TESTS ONLY TO FULL-BUILD" + + common=$(comm -1 -2 <(rev ./tmp/only-in-full | cut -d'-' -f2- | rev | uniq) <(rev ./tmp/only-in-libs | cut -d'-' -f2- | rev | uniq)) + + major=() + minor=() + patch=() + + for dep in $common; do + full=$(grep -E "^$dep-([0-9]+\.)*[0-9]" ./tmp/only-in-full | rev | cut -d'-' -f1 | rev) + if [[ $(echo $full | awk -F. '{print NF-1}') -lt 3 ]]; then + n=$(((3 - $(echo $full | awk -F. '{print NF-1}'))*2)) + sff=".0.0.0.0" + full="$full${sff:0:$n}" + fi + libs=$(grep -E "^$dep-([0-9]+\.)*[0-9]" ./tmp/only-in-libs | rev | cut -d'-' -f1 | rev) + if [[ $(echo $libs | awk -F. '{print NF-1}') -lt 3 ]]; then + n=$(((3 - $(echo $libs | awk -F. '{print NF-1}'))*2)) + sff=".0.0.0.0" + libs="$libs${sff:0:$n}" + fi + verDiff=$(printf "%s\n" "$full" "$libs" | sed -e 'N;s/^\(.*\).*\n\1.*$/\1/' | awk -F. '{print NF-1}') + case $verDiff in + 0) + major+=("$dep $full -> $libs") + ;; + 1) + major+=("$dep $full -> $libs") + ;; + 2) + minor+=("$dep $full -> $libs") + ;; + *) + patch+=("$dep $full -> $libs") + ;; + esac + done + + echo -e "- MAJOR BUMPS" + printf '%s\n' "${major[@]}" | sed 's/^\(.\+\)/ - \1/g' + + echo -e "- MINOR BUMPS" + printf '%s\n' "${minor[@]}" | sed 's/^\(.\+\)/ - \1/g' + + echo -e "- PATCH BUMPS" + printf '%s\n' "${patch[@]}" | sed 's/^\(.\+\)/ - \1/g' + + if [[ -n $GH && ${#major[@]} ]]; then + str=$(printf '%s\n' "${major[@]}") + echo "::warning title=Major bumps detected::$str" fi - libs=$(grep -E "^$dep-([0-9]+\.)*[0-9]" ./tmp/only-in-libs | rev | cut -d'-' -f1 | rev) - if [[ $(echo $libs | awk -F. '{print NF-1}') -lt 3 ]]; then - n=$(((3 - $(echo $libs | awk -F. '{print NF-1}'))*2)) - sff=".0.0.0.0" - libs="$libs${sff:0:$n}" - fi - verDiff=$(printf "%s\n" "$full" "$libs" | sed -e 'N;s/^\(.*\).*\n\1.*$/\1/' | awk -F. '{print NF-1}') - case $verDiff in - 0) - major+=("$dep $full -> $libs") - ;; - 1) - major+=("$dep $full -> $libs") - ;; - 2) - minor+=("$dep $full -> $libs") - ;; - *) - patch+=("$dep $full -> $libs") - ;; - esac -done - -echo -e "- MAJOR BUMPS" -printf '%s\n' "${major[@]}" | sed 's/^\(.\+\)/ - \1/g' - -echo -e "- MINOR BUMPS" -printf '%s\n' "${minor[@]}" | sed 's/^\(.\+\)/ - \1/g' - -echo -e "- PATCH BUMPS" -printf '%s\n' "${patch[@]}" | sed 's/^\(.\+\)/ - \1/g' - -if [[ -n $GH && ${#major[@]} ]]; then - str=$(printf '%s\n' "${major[@]}") - echo "::warning title=Major bumps detected::$str" fi - -rm -r ./tmp diff --git a/sop-extras/src/Data/SOP/Counting.hs b/sop-extras/src/Data/SOP/Counting.hs index c362be22ef..b434370a6c 100644 --- a/sop-extras/src/Data/SOP/Counting.hs +++ b/sop-extras/src/Data/SOP/Counting.hs @@ -43,7 +43,7 @@ import qualified Data.Foldable as Foldable import Data.Kind import Data.SOP.BasicFunctors import Data.SOP.Constraint -import Data.SOP.Dict +import Data.SOP.Dict (Dict (..), all_NP) import Data.SOP.NonEmpty import Data.SOP.Strict diff --git a/sop-extras/src/Data/SOP/Index.hs b/sop-extras/src/Data/SOP/Index.hs index 052784af75..a7c2779297 100644 --- a/sop-extras/src/Data/SOP/Index.hs +++ b/sop-extras/src/Data/SOP/Index.hs @@ -38,7 +38,7 @@ import Data.Kind (Type) import Data.Proxy import Data.SOP.BasicFunctors import Data.SOP.Constraint -import Data.SOP.Dict +import Data.SOP.Dict (Dict (..)) import Data.SOP.Sing import Data.SOP.Strict import Data.Word