From f4e6540da1082d6f63d42d601d0abd1393d183f3 Mon Sep 17 00:00:00 2001 From: Phil de Joux Date: Thu, 28 Dec 2023 12:35:23 -0500 Subject: [PATCH 1/4] Use $setup for Cabal-described doctests --- Cabal-described/src/Distribution/Utils/CharSet.hs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Cabal-described/src/Distribution/Utils/CharSet.hs b/Cabal-described/src/Distribution/Utils/CharSet.hs index 45bfbb1300b..3cb9ba500a8 100644 --- a/Cabal-described/src/Distribution/Utils/CharSet.hs +++ b/Cabal-described/src/Distribution/Utils/CharSet.hs @@ -240,3 +240,8 @@ alphanum = foldl' (flip insert) empty [ c | c <- [ minBound .. maxBound ], isAlp upper :: CharSet upper = foldl' (flip insert) empty [ c | c <- [ minBound .. maxBound ], isUpper c ] {-# NOINLINE upper #-} + +-- $setup +-- Use -XOverloadedStrings to avoid the error: Couldn't match type ‘[Char]’ with ‘CharSet’ +-- >>> :set -XOverloadedStrings +-- >>> import Prelude (length) \ No newline at end of file From bff2b5bdc150acbafdb1c638e982abdcc943f66d Mon Sep 17 00:00:00 2001 From: Phil de Joux Date: Thu, 28 Dec 2023 15:05:49 -0500 Subject: [PATCH 2/4] Update doctest expectations in cabal-install --- .../src/Distribution/Client/IndexUtils/ActiveRepos.hs | 8 ++++---- .../src/Distribution/Client/IndexUtils/IndexState.hs | 4 ++-- cabal-install/src/Distribution/Client/Types/RepoName.hs | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/cabal-install/src/Distribution/Client/IndexUtils/ActiveRepos.hs b/cabal-install/src/Distribution/Client/IndexUtils/ActiveRepos.hs index e65000e6b98..daa4ec86355 100644 --- a/cabal-install/src/Distribution/Client/IndexUtils/ActiveRepos.hs +++ b/cabal-install/src/Distribution/Client/IndexUtils/ActiveRepos.hs @@ -70,7 +70,7 @@ instance Pretty ActiveRepos where -- Just (ActiveRepos [ActiveRepoRest CombineStrategyMerge]) -- -- >>> simpleParsec "hackage.haskell.org, :rest, head.hackage:override" :: Maybe ActiveRepos --- Just (ActiveRepos [ActiveRepo (RepoName "hackage.haskell.org") CombineStrategyMerge,ActiveRepoRest CombineStrategyMerge,ActiveRepo (RepoName "head.hackage") CombineStrategyOverride]) +-- Just (ActiveRepos [ActiveRepo (RepoName {unRepoName = "hackage.haskell.org"}) CombineStrategyMerge,ActiveRepoRest CombineStrategyMerge,ActiveRepo (RepoName {unRepoName = "head.hackage"}) CombineStrategyOverride]) instance Parsec ActiveRepos where parsec = ActiveRepos [] <$ P.try (P.string ":none") @@ -148,13 +148,13 @@ instance Parsec CombineStrategy where -- -- >>> let repos = [RepoName "a", RepoName "b", RepoName "c"] -- >>> organizeByRepos (ActiveRepos [ActiveRepoRest CombineStrategyMerge]) id repos --- Right [(RepoName "a",CombineStrategyMerge),(RepoName "b",CombineStrategyMerge),(RepoName "c",CombineStrategyMerge)] +-- Right [(RepoName {unRepoName = "a"},CombineStrategyMerge),(RepoName {unRepoName = "b"},CombineStrategyMerge),(RepoName {unRepoName = "c"},CombineStrategyMerge)] -- -- >>> organizeByRepos (ActiveRepos [ActiveRepo (RepoName "b") CombineStrategyOverride, ActiveRepoRest CombineStrategyMerge]) id repos --- Right [(RepoName "b",CombineStrategyOverride),(RepoName "a",CombineStrategyMerge),(RepoName "c",CombineStrategyMerge)] +-- Right [(RepoName {unRepoName = "b"},CombineStrategyOverride),(RepoName {unRepoName = "a"},CombineStrategyMerge),(RepoName {unRepoName = "c"},CombineStrategyMerge)] -- -- >>> organizeByRepos (ActiveRepos [ActiveRepoRest CombineStrategyMerge, ActiveRepo (RepoName "b") CombineStrategyOverride]) id repos --- Right [(RepoName "a",CombineStrategyMerge),(RepoName "c",CombineStrategyMerge),(RepoName "b",CombineStrategyOverride)] +-- Right [(RepoName {unRepoName = "a"},CombineStrategyMerge),(RepoName {unRepoName = "c"},CombineStrategyMerge),(RepoName {unRepoName = "b"},CombineStrategyOverride)] -- -- >>> organizeByRepos (ActiveRepos [ActiveRepoRest CombineStrategyMerge, ActiveRepo (RepoName "d") CombineStrategyOverride]) id repos -- Left "no repository provided d" diff --git a/cabal-install/src/Distribution/Client/IndexUtils/IndexState.hs b/cabal-install/src/Distribution/Client/IndexUtils/IndexState.hs index 8acf2b3bdc3..0e9cb6a73d3 100644 --- a/cabal-install/src/Distribution/Client/IndexUtils/IndexState.hs +++ b/cabal-install/src/Distribution/Client/IndexUtils/IndexState.hs @@ -68,10 +68,10 @@ instance Pretty TotalIndexState where -- Just (TIS IndexStateHead (fromList [])) -- -- >>> simpleParsec "2020-02-04T12:34:56Z, hackage.haskell.org HEAD" :: Maybe TotalIndexState --- Just (TIS (IndexStateTime (TS 1580819696)) (fromList [(RepoName "hackage.haskell.org",IndexStateHead)])) +-- Just (TIS (IndexStateTime (TS 1580819696)) (fromList [(RepoName {unRepoName = "hackage.haskell.org"},IndexStateHead)])) -- -- >>> simpleParsec "hackage.haskell.org 2020-02-04T12:34:56Z" :: Maybe TotalIndexState --- Just (TIS IndexStateHead (fromList [(RepoName "hackage.haskell.org",IndexStateTime (TS 1580819696))])) +-- Just (TIS IndexStateHead (fromList [(RepoName {unRepoName = "hackage.haskell.org"},IndexStateTime (TS 1580819696))])) instance Parsec TotalIndexState where parsec = normalise . foldl' add headTotalIndexState <$> parsecLeadingCommaNonEmpty single0 where diff --git a/cabal-install/src/Distribution/Client/Types/RepoName.hs b/cabal-install/src/Distribution/Client/Types/RepoName.hs index 2eb2fb15fc8..1a9b8012aa9 100644 --- a/cabal-install/src/Distribution/Client/Types/RepoName.hs +++ b/cabal-install/src/Distribution/Client/Types/RepoName.hs @@ -29,7 +29,7 @@ instance Pretty RepoName where -- | -- -- >>> simpleParsec "hackage.haskell.org" :: Maybe RepoName --- Just (RepoName "hackage.haskell.org") +-- Just (RepoName {unRepoName = "hackage.haskell.org"}) -- -- >>> simpleParsec "0123" :: Maybe RepoName -- Nothing From 773600ba016e25077eeb59ad93c7c51cd41e19f8 Mon Sep 17 00:00:00 2001 From: Phil de Joux Date: Thu, 28 Dec 2023 12:36:39 -0500 Subject: [PATCH 3/4] Add Cabal-described to Makefile doctest --- Makefile | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 9718bfd696c..f38f93309f9 100644 --- a/Makefile +++ b/Makefile @@ -3,6 +3,7 @@ CABALBUILD := cabal build CABALRUN := cabal run +DOCTEST := cabal repl --with-ghc=doctest --repl-options="-w" --project-file=cabal.project.doctest # default rules @@ -85,9 +86,9 @@ ghcid-cli : # https://github.com/haskell/cabal/issues/8734 # Just as well, cabal-install(-solver) doctests (the target below) bitrotted and need some care. doctest : - cabal repl --with-ghc=doctest --build-depends=QuickCheck --build-depends=template-haskell --repl-options="-w" --project-file="cabal.project.doctest" Cabal-syntax - cabal repl --with-ghc=doctest --build-depends=QuickCheck --build-depends=template-haskell --repl-options="-w" --project-file="cabal.project.doctest" Cabal - + $(DOCTEST) Cabal-syntax + $(DOCTEST) Cabal-described + $(DOCTEST) --build-depends=QuickCheck Cabal # This is not run as part of validate.sh (we need hackage-security, which is tricky to get). doctest-cli : From 8dd381e8646749f1aafa58af6df5206a270d8bfc Mon Sep 17 00:00:00 2001 From: Phil de Joux Date: Thu, 28 Dec 2023 15:08:52 -0500 Subject: [PATCH 4/4] Add cabal-install to doctests --- Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile b/Makefile index f38f93309f9..b37298f2aee 100644 --- a/Makefile +++ b/Makefile @@ -89,6 +89,7 @@ doctest : $(DOCTEST) Cabal-syntax $(DOCTEST) Cabal-described $(DOCTEST) --build-depends=QuickCheck Cabal + $(DOCTEST) cabal-install # This is not run as part of validate.sh (we need hackage-security, which is tricky to get). doctest-cli :