module Distribution.Types.PkgconfigName
( PkgconfigName, unPkgconfigName, mkPkgconfigName
) where
import Prelude ()
import Distribution.Compat.Prelude
import Distribution.Utils.ShortText
import Distribution.Pretty
import Distribution.Parsec.Class
import Distribution.Text
import qualified Distribution.Compat.CharParsing as P
import qualified Distribution.Compat.ReadP as Parse
import qualified Text.PrettyPrint as Disp
newtype PkgconfigName = PkgconfigName ShortText
deriving (Generic, Read, Show, Eq, Ord, Typeable, Data)
unPkgconfigName :: PkgconfigName -> String
unPkgconfigName (PkgconfigName s) = fromShortText s
mkPkgconfigName :: String -> PkgconfigName
mkPkgconfigName = PkgconfigName . toShortText
instance IsString PkgconfigName where
fromString = mkPkgconfigName
instance Binary PkgconfigName
instance Pretty PkgconfigName where
pretty = Disp.text . unPkgconfigName
instance Parsec PkgconfigName where
parsec = mkPkgconfigName <$> P.munch1 (\c -> isAlphaNum c || c `elem` "+-._")
instance Text PkgconfigName where
parse = mkPkgconfigName
<$> Parse.munch1 (\c -> isAlphaNum c || c `elem` "+-._")
instance NFData PkgconfigName where
rnf (PkgconfigName pkg) = rnf pkg