{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
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, Typeable)
unAbiHash :: AbiHash -> String
unAbiHash (AbiHash h) = fromShortText h
mkAbiHash :: String -> AbiHash
mkAbiHash = AbiHash . toShortText
instance IsString AbiHash where
fromString = mkAbiHash
instance Binary AbiHash
instance Structured AbiHash
instance NFData AbiHash where rnf = genericRnf
instance Pretty AbiHash where
pretty = text . unAbiHash
instance Parsec AbiHash where
parsec = fmap mkAbiHash (P.munch isAlphaNum)