diff options
-rw-r--r-- | libraries/base/Data/Version.hs | 8 | ||||
-rwxr-xr-x | libraries/base/GHC/Exts.hs | 7 | ||||
-rw-r--r-- | libraries/base/changelog.md | 6 | ||||
-rw-r--r-- | testsuite/tests/overloadedlists/should_fail/overloadedlistsfail01.stderr | 9 |
4 files changed, 27 insertions, 3 deletions
diff --git a/libraries/base/Data/Version.hs b/libraries/base/Data/Version.hs index 3761d81bb9..1a14fd08f4 100644 --- a/libraries/base/Data/Version.hs +++ b/libraries/base/Data/Version.hs @@ -32,6 +32,8 @@ module Data.Version ( Version(..), -- * A concrete representation of @Version@ showVersion, parseVersion, + -- * Constructor function + makeVersion ) where import Control.Monad ( Monad(..), liftM ) @@ -121,3 +123,9 @@ parseVersion :: ReadP Version parseVersion = do branch <- sepBy1 (liftM read (munch1 isDigit)) (char '.') tags <- many (char '-' >> munch1 isAlphaNum) return Version{versionBranch=branch, versionTags=tags} + +-- | Construct tag-less 'Version' +-- +-- @since 4.8.0.0 +makeVersion :: [Int] -> Version +makeVersion b = Version b [] diff --git a/libraries/base/GHC/Exts.hs b/libraries/base/GHC/Exts.hs index 93de419eb6..294267835e 100755 --- a/libraries/base/GHC/Exts.hs +++ b/libraries/base/GHC/Exts.hs @@ -84,6 +84,7 @@ import Data.String import Data.OldList import Data.Data import Data.Ord +import Data.Version ( Version(..), makeVersion ) import qualified Debug.Trace -- XXX This should really be in Data.Tuple, where the definitions are @@ -177,3 +178,9 @@ instance IsList [a] where type (Item [a]) = a fromList = id toList = id + +-- | @since 4.8.0.0 +instance IsList Version where + type (Item Version) = Int + fromList = makeVersion + toList = versionBranch diff --git a/libraries/base/changelog.md b/libraries/base/changelog.md index 00da7cee8b..76a6a191dd 100644 --- a/libraries/base/changelog.md +++ b/libraries/base/changelog.md @@ -12,6 +12,12 @@ * Add `System.Exit.die` + * Deprecate `versionTags` field of `Data.Version.Version`. + Add `makeVersion :: [Int] -> Version` constructor function to aid + migration to a future `versionTags`-less `Version`. + + * Add `IsList Version` instance + * Weaken RealFloat constraints on some `Data.Complex` functions * Add `Control.Monad.(<$!>)` as a strict version of `(<$>)` diff --git a/testsuite/tests/overloadedlists/should_fail/overloadedlistsfail01.stderr b/testsuite/tests/overloadedlists/should_fail/overloadedlistsfail01.stderr index 9f3a8325c2..6516beb078 100644 --- a/testsuite/tests/overloadedlists/should_fail/overloadedlistsfail01.stderr +++ b/testsuite/tests/overloadedlists/should_fail/overloadedlistsfail01.stderr @@ -3,10 +3,11 @@ overloadedlistsfail01.hs:5:8: No instance for (Show a0) arising from a use of ‘print’ The type variable ‘a0’ is ambiguous Note: there are several potential instances: + instance [safe] Show Data.Version.Version + -- Defined in ‘Data.Version’ instance Show a => Show (Maybe a) -- Defined in ‘GHC.Show’ instance Show Ordering -- Defined in ‘GHC.Show’ - instance Show Integer -- Defined in ‘GHC.Show’ - ...plus 22 others + ...plus 23 others In the expression: print [1] In an equation for ‘main’: main = print [1] @@ -14,7 +15,9 @@ overloadedlistsfail01.hs:5:14: No instance for (GHC.Exts.IsList a0) arising from an overloaded list The type variable ‘a0’ is ambiguous - Note: there is a potential instance available: + Note: there are several potential instances: + instance GHC.Exts.IsList Data.Version.Version + -- Defined in ‘GHC.Exts’ instance GHC.Exts.IsList [a] -- Defined in ‘GHC.Exts’ In the first argument of ‘print’, namely ‘[1]’ In the expression: print [1] |