Commit b9dbc12c authored by Oleg Grenrus's avatar Oleg Grenrus

Add Described OS and Arch

parent e015931f
......@@ -50,6 +50,7 @@ import Distribution.Utils.Generic (lowercase)
import Distribution.Parsec
import Distribution.Pretty
import Distribution.FieldGrammar.Described
import qualified Distribution.Compat.CharParsing as P
import qualified Text.PrettyPrint as Disp
......@@ -132,6 +133,13 @@ instance Pretty OS where
instance Parsec OS where
parsec = classifyOS Compat <$> parsecIdent
instance Described OS where
describe _ = REUnion
[ fromString al
| os <- knownOSs
, al <- prettyShow os : osAliases Compat os
]
classifyOS :: ClassificationStrictness -> String -> OS
classifyOS strictness s =
fromMaybe (OtherOS s) $ lookup (lowercase s) osMap
......@@ -198,6 +206,12 @@ instance Pretty Arch where
instance Parsec Arch where
parsec = classifyArch Strict <$> parsecIdent
instance Described Arch where
describe _ = REUnion
[ fromString (prettyShow arch)
| arch <- knownArches
]
classifyArch :: ClassificationStrictness -> String -> Arch
classifyArch strictness s =
fromMaybe (OtherArch s) $ lookup (lowercase s) archMap
......
......@@ -25,6 +25,7 @@ import Distribution.Types.PackageId (PackageIdentifier)
import Distribution.Types.PackageName (PackageName)
import Distribution.Types.PackageVersionConstraint (PackageVersionConstraint)
import Distribution.Types.Version (Version)
import Distribution.System (OS, Arch)
import Distribution.Types.VersionRange (VersionRange)
import qualified RERE as RE
......@@ -43,6 +44,8 @@ tests = testGroup "Described"
, testDescribed (Proxy :: Proxy VersionRange)
, testDescribed (Proxy :: Proxy FlagName)
, testDescribed (Proxy :: Proxy ModuleName)
, testDescribed (Proxy :: Proxy OS)
, testDescribed (Proxy :: Proxy Arch)
]
-------------------------------------------------------------------------------
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment