module Distribution.Types.PkgconfigName
( PkgconfigName, unPkgconfigName, mkPkgconfigName
) where
import Prelude ()
import Distribution.Compat.Prelude
import Distribution.Utils.ShortText
import Distribution.Pretty
import Distribution.Parsec
import qualified Distribution.Compat.CharParsing as P
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 Structured PkgconfigName
instance Pretty PkgconfigName where
pretty = Disp.text . unPkgconfigName
instance Parsec PkgconfigName where
parsec = mkPkgconfigName <$> P.munch1 isNameChar where
isNameChar '-' = True
isNameChar '_' = True
isNameChar '.' = True
isNameChar '+' = True
isNameChar c = isAlphaNum c
instance NFData PkgconfigName where
rnf (PkgconfigName pkg) = rnf pkg