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 diff --git a/Makefile b/Makefile index 9718bfd696c..b37298f2aee 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,10 @@ 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 + $(DOCTEST) cabal-install # This is not run as part of validate.sh (we need hackage-security, which is tricky to get). doctest-cli : 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