module Distribution.Types.AbiHash
( AbiHash, unAbiHash, mkAbiHash
) where
import Prelude ()
import Distribution.Compat.Prelude
import Distribution.Utils.ShortText
import qualified Distribution.Compat.CharParsing as P
import Distribution.Pretty
import Distribution.Parsec
import Text.PrettyPrint (text)
newtype AbiHash = AbiHash ShortText
deriving (Eq, Show, Read, Generic)
unAbiHash :: AbiHash -> String
unAbiHash (AbiHash h) = fromShortText h
mkAbiHash :: String -> AbiHash
mkAbiHash = AbiHash . toShortText
instance IsString AbiHash where
fromString = mkAbiHash
instance Binary AbiHash
instance NFData AbiHash where rnf = genericRnf
instance Pretty AbiHash where
pretty = text . unAbiHash
instance Parsec AbiHash where
parsec = fmap mkAbiHash (P.munch isAlphaNum)