{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DeriveGeneric #-}
module Distribution.Types.PkgconfigName
( PkgconfigName, unPkgconfigName, mkPkgconfigName
) where
import Prelude ()
import Distribution.Compat.Prelude
import Distribution.Utils.ShortText
import qualified Text.PrettyPrint as Disp
import Distribution.Compat.ReadP
import Distribution.Text
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 Text PkgconfigName where
disp = Disp.text . unPkgconfigName
parse = mkPkgconfigName
<$> munch1 (\c -> isAlphaNum c || c `elem` "+-._")
instance NFData PkgconfigName where
rnf (PkgconfigName pkg) = rnf pkg