From: simonmar Date: Tue, 9 Nov 2004 17:02:23 +0000 (+0000) Subject: [project @ 2004-11-09 17:02:23 by simonmar] X-Git-Tag: nhc98-1-18-release~198 X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=04b702d6660f8fcae2d50277d596c92cd6766a84;p=ghc-base.git [project @ 2004-11-09 17:02:23 by simonmar] Make this compile with GHC < 6.3 --- diff --git a/Data/Version.hs b/Data/Version.hs index 959baf7..beda6ba 100644 --- a/Data/Version.hs +++ b/Data/Version.hs @@ -30,8 +30,18 @@ module Data.Version ( showVersion, parseVersion, ) where +#if __GLASGOW_HASKELL__ < 603 +import Distribution.Compat.ReadP +#else import Text.ParserCombinators.ReadP +#endif + +#if __GLASGOW_HASKELL__ < 602 +import Data.Dynamic ( Typeable(..), TyCon, mkTyCon, mkAppTy ) +#else import Data.Typeable ( Typeable ) +#endif + import Data.List ( intersperse ) import Control.Monad ( liftM ) import Data.Char ( isDigit, isAlphaNum ) @@ -79,7 +89,19 @@ data Version = -- The interpretation of the list of tags is entirely dependent -- on the entity that this version applies to. } - deriving (Read,Show,Typeable) + deriving (Read,Show +#if __GLASGOW_HASKELL__ >= 602 + ,Typeable +#endif + ) + +#if __GLASGOW_HASKELL__ < 602 +versionTc :: TyCon +versionTc = mkTyCon "()" + +instance Typeable Version where + typeOf _ = mkAppTy versionTc [] +#endif instance Eq Version where v1 == v2 = versionBranch v1 == versionBranch v2 @@ -103,7 +125,11 @@ showVersion (Version branch tags) -- | A parser for versions in the format produced by 'showVersion'. -- +#if __GLASGOW_HASKELL__ < 602 +parseVersion :: ReadP r Version +#else parseVersion :: ReadP Version +#endif parseVersion = do branch <- sepBy1 (liftM read $ munch1 isDigit) (char '.') tags <- many (char '-' >> munch1 isAlphaNum) return Version{versionBranch=branch, versionTags=tags}