diff --git a/Cabal/Distribution/Compat/Prelude.hs b/Cabal/Distribution/Compat/Prelude.hs index 21eec8d2217..0242c438d37 100644 --- a/Cabal/Distribution/Compat/Prelude.hs +++ b/Cabal/Distribution/Compat/Prelude.hs @@ -40,6 +40,7 @@ module Distribution.Compat.Prelude ( Binary (..), Alternative (..), MonadPlus (..), + IsString (..), -- * Some types IO, NoCallStackIO, @@ -131,6 +132,7 @@ import Data.List (intercalate, intersperse, isPrefixOf, isSuffixOf, nub, nubBy, sort, sortBy, unfoldr) import Data.Maybe +import Data.String (IsString (..)) import Data.Int import Data.Word diff --git a/Cabal/Distribution/ModuleName.hs b/Cabal/Distribution/ModuleName.hs index 1fa1435b532..ffb60f34d60 100644 --- a/Cabal/Distribution/ModuleName.hs +++ b/Cabal/Distribution/ModuleName.hs @@ -76,12 +76,12 @@ simple str = ModuleName (stlFromStrings [str]) -- an error if it is used with a string that is not a valid module name. If you -- are parsing user input then use 'Distribution.Text.simpleParse' instead. -- -fromString :: String -> ModuleName -fromString string = fromComponents (split string) - where - split cs = case break (=='.') cs of - (chunk,[]) -> chunk : [] - (chunk,_:rest) -> chunk : split rest +instance IsString ModuleName where + fromString string = fromComponents (split string) + where + split cs = case break (=='.') cs of + (chunk,[]) -> chunk : [] + (chunk,_:rest) -> chunk : split rest -- | Construct a 'ModuleName' from valid module components, i.e. parts -- separated by dots. diff --git a/Cabal/Distribution/Package.hs b/Cabal/Distribution/Package.hs index 899f0ec0842..6c9682b68cf 100644 --- a/Cabal/Distribution/Package.hs +++ b/Cabal/Distribution/Package.hs @@ -89,6 +89,12 @@ unPackageName (PackageName s) = fromShortText s mkPackageName :: String -> PackageName mkPackageName = PackageName . toShortText +-- | 'mkPackageName' +-- +-- @since 2.0 +instance IsString PackageName where + fromString = mkPackageName + instance Binary PackageName instance Text PackageName where @@ -123,6 +129,12 @@ unPkgconfigName (PkgconfigName s) = fromShortText s mkPkgconfigName :: String -> PkgconfigName mkPkgconfigName = PkgconfigName . toShortText +-- | 'mkPkgconfigName' +-- +-- @since 2.0 +instance IsString PkgconfigName where + fromString = mkPkgconfigName + instance Binary PkgconfigName -- pkg-config allows versions and other letters in package names, eg @@ -215,6 +227,12 @@ newtype ComponentId = ComponentId ShortText mkComponentId :: String -> ComponentId mkComponentId = ComponentId . toShortText +-- | 'mkComponentId' +-- +-- @since 2.0 +instance IsString ComponentId where + fromString = mkComponentId + -- | Convert 'ComponentId' to 'String' -- -- @since 2.0 @@ -288,15 +306,21 @@ instance Text UnitId where disp = text . unUnitId parse = mkUnitId <$> Parse.munch1 (\c -> isAlphaNum c || c `elem` "-_.+") -unUnitId :: UnitId -> String -unUnitId (UnitId s) = fromShortText s - -- | If you need backwards compatibility, consider using 'display' -- instead, which is supported by all versions of Cabal. -- +unUnitId :: UnitId -> String +unUnitId (UnitId s) = fromShortText s + mkUnitId :: String -> UnitId mkUnitId = UnitId . toShortText +-- | 'mkUnitId' +-- +-- @since 2.0 +instance IsString UnitId where + fromString = mkUnitId + -- | A 'UnitId' for a definite package. The 'DefUnitId' invariant says -- that a 'UnitId' identified this way is definite; i.e., it has no -- unfilled holes. @@ -388,6 +412,12 @@ unAbiHash (AbiHash h) = fromShortText h mkAbiHash :: String -> AbiHash mkAbiHash = AbiHash . toShortText +-- | 'mkAbiHash' +-- +-- @since 2.0 +instance IsString AbiHash where + fromString = mkAbiHash + instance Binary AbiHash instance Text AbiHash where diff --git a/Cabal/Distribution/Types/GenericPackageDescription.hs b/Cabal/Distribution/Types/GenericPackageDescription.hs index 4e9d82e831a..01d9936dedc 100644 --- a/Cabal/Distribution/Types/GenericPackageDescription.hs +++ b/Cabal/Distribution/Types/GenericPackageDescription.hs @@ -102,6 +102,12 @@ newtype FlagName = FlagName ShortText mkFlagName :: String -> FlagName mkFlagName = FlagName . toShortText +-- | 'mkFlagName' +-- +-- @since 2.0 +instance IsString FlagName where + fromString = mkFlagName + -- | Convert 'FlagName' to 'String' -- -- @since 2.0 diff --git a/Cabal/Distribution/Types/UnqualComponentName.hs b/Cabal/Distribution/Types/UnqualComponentName.hs index 3ead6f5f1b1..1996ff0997e 100644 --- a/Cabal/Distribution/Types/UnqualComponentName.hs +++ b/Cabal/Distribution/Types/UnqualComponentName.hs @@ -44,6 +44,12 @@ unUnqualComponentName (UnqualComponentName s) = fromShortText s mkUnqualComponentName :: String -> UnqualComponentName mkUnqualComponentName = UnqualComponentName . toShortText +-- | 'mkUnqualComponentName' +-- +-- @since 2.0 +instance IsString UnqualComponentName where + fromString = mkUnqualComponentName + instance Binary UnqualComponentName instance Text UnqualComponentName where diff --git a/Cabal/Distribution/Utils/ShortText.hs b/Cabal/Distribution/Utils/ShortText.hs index bc413e05d4c..dd2f594b3a5 100644 --- a/Cabal/Distribution/Utils/ShortText.hs +++ b/Cabal/Distribution/Utils/ShortText.hs @@ -17,8 +17,6 @@ import Prelude () import Distribution.Compat.Prelude import Distribution.Utils.String -import Data.String (IsString(..)) - #if defined(MIN_VERSION_bytestring) # if MIN_VERSION_bytestring(0,10,4) # define HAVE_SHORTBYTESTRING 1 diff --git a/cabal-install/Distribution/Client/Init.hs b/cabal-install/Distribution/Client/Init.hs index 3b7bf9b9f3c..e06a689bb1f 100644 --- a/cabal-install/Distribution/Client/Init.hs +++ b/cabal-install/Distribution/Client/Init.hs @@ -53,7 +53,7 @@ import Distribution.Version import Distribution.Verbosity ( Verbosity ) import Distribution.ModuleName - ( ModuleName, fromString ) -- And for the Text instance + ( ModuleName ) -- And for the Text instance import Distribution.InstalledPackageInfo ( InstalledPackageInfo, sourcePackageId, exposed ) import qualified Distribution.Package as P diff --git a/cabal-testsuite/cabal-testsuite.cabal b/cabal-testsuite/cabal-testsuite.cabal index 94a350596ec..da23e1af700 100644 --- a/cabal-testsuite/cabal-testsuite.cabal +++ b/cabal-testsuite/cabal-testsuite.cabal @@ -32,13 +32,13 @@ library Test.Cabal.Server Test.Cabal.Monad build-depends: - aeson, + aeson == 1.1.*, attoparsec, async, base, bytestring, transformers, - optparse-applicative, + optparse-applicative ==0.12.*, process, directory, filepath, diff --git a/stack.yaml b/stack.yaml index 9fd01beda5c..b3d801a9640 100644 --- a/stack.yaml +++ b/stack.yaml @@ -40,7 +40,7 @@ extra-deps: - stm-2.4.4.1 - tagged-0.8.4 - tar-0.5.0.3 -- tasty-0.11.0.3 +- tasty-0.11.0.4 - tasty-hunit-0.9.2 - tasty-quickcheck-0.8.4 - text-1.2.2.1