module Data.Version ( Version(..), showVersion, parseVersion, ) where import Prelude #if __GLASGOW_HASKELL__ || __HUGS__ || __NHC__ import Text.ParserCombinators.ReadP #else import Distribution.Compat.ReadP #endif #if !__GLASGOW_HASKELL__ import Data.Typeable ( Typeable, TyCon, mkTyCon, mkTyConApp ) #else import Data.Typeable ( Typeable ) #endif import Data.List ( intersperse, sort ) import Control.Monad ( liftM ) import Data.Char ( isDigit, isAlphaNum ) data Version = Version { versionBranch :: [Int], versionTags :: [String] } deriving (Read,Show #if __GLASGOW_HASKELL__ ,Typeable #endif ) #if !__GLASGOW_HASKELL__ versionTc :: TyCon versionTc = mkTyCon "Version" instance Typeable Version where typeOf _ = mkTyConApp versionTc [] #endif instance Eq Version where v1 == v2 = versionBranch v1 == versionBranch v2 && sort (versionTags v1) == sort (versionTags v2) instance Ord Version where v1 `compare` v2 = versionBranch v1 `compare` versionBranch v2 showVersion :: Version -> String showVersion (Version branch tags) = concat (intersperse "." (map show branch)) ++ concatMap ('-':) tags #if __GLASGOW_HASKELL__ || __HUGS__ parseVersion :: ReadP Version #elif __NHC__ parseVersion :: ReadPN r Version #else parseVersion :: ReadP r Version #endif parseVersion = do branch <- sepBy1 (liftM read $ munch1 isDigit) (char '.') tags <- many (char '-' >> munch1 isAlphaNum) return Version{versionBranch=branch, versionTags=tags}
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4