{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE StandaloneDeriving #-}

module Cardano.Chain.Genesis.Hash
  ( GenesisHash (..),
  )
where

import Cardano.Binary (FromCBOR, Raw, ToCBOR)
import Cardano.Crypto.Hashing (Hash)
import Cardano.Prelude
import Data.Aeson (ToJSON)
import NoThunks.Class (NoThunks (..))

newtype GenesisHash = GenesisHash
  { GenesisHash -> Hash Raw
unGenesisHash :: Hash Raw
  }
  deriving (GenesisHash -> GenesisHash -> Bool
(GenesisHash -> GenesisHash -> Bool)
-> (GenesisHash -> GenesisHash -> Bool) -> Eq GenesisHash
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GenesisHash -> GenesisHash -> Bool
$c/= :: GenesisHash -> GenesisHash -> Bool
== :: GenesisHash -> GenesisHash -> Bool
$c== :: GenesisHash -> GenesisHash -> Bool
Eq, (forall x. GenesisHash -> Rep GenesisHash x)
-> (forall x. Rep GenesisHash x -> GenesisHash)
-> Generic GenesisHash
forall x. Rep GenesisHash x -> GenesisHash
forall x. GenesisHash -> Rep GenesisHash x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GenesisHash x -> GenesisHash
$cfrom :: forall x. GenesisHash -> Rep GenesisHash x
Generic, GenesisHash -> ()
(GenesisHash -> ()) -> NFData GenesisHash
forall a. (a -> ()) -> NFData a
rnf :: GenesisHash -> ()
$crnf :: GenesisHash -> ()
NFData, Typeable GenesisHash
Decoder s GenesisHash
Typeable GenesisHash
-> (forall s. Decoder s GenesisHash)
-> (Proxy GenesisHash -> Text)
-> FromCBOR GenesisHash
Proxy GenesisHash -> Text
forall s. Decoder s GenesisHash
forall a.
Typeable a
-> (forall s. Decoder s a) -> (Proxy a -> Text) -> FromCBOR a
label :: Proxy GenesisHash -> Text
$clabel :: Proxy GenesisHash -> Text
fromCBOR :: Decoder s GenesisHash
$cfromCBOR :: forall s. Decoder s GenesisHash
$cp1FromCBOR :: Typeable GenesisHash
FromCBOR, Typeable GenesisHash
Typeable GenesisHash
-> (GenesisHash -> Encoding)
-> ((forall t. ToCBOR t => Proxy t -> Size)
    -> Proxy GenesisHash -> Size)
-> ((forall t. ToCBOR t => Proxy t -> Size)
    -> Proxy [GenesisHash] -> Size)
-> ToCBOR GenesisHash
GenesisHash -> Encoding
(forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [GenesisHash] -> Size
(forall t. ToCBOR t => Proxy t -> Size)
-> Proxy GenesisHash -> Size
forall a.
Typeable a
-> (a -> Encoding)
-> ((forall t. ToCBOR t => Proxy t -> Size) -> Proxy a -> Size)
-> ((forall t. ToCBOR t => Proxy t -> Size) -> Proxy [a] -> Size)
-> ToCBOR a
encodedListSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [GenesisHash] -> Size
$cencodedListSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [GenesisHash] -> Size
encodedSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy GenesisHash -> Size
$cencodedSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy GenesisHash -> Size
toCBOR :: GenesisHash -> Encoding
$ctoCBOR :: GenesisHash -> Encoding
$cp1ToCBOR :: Typeable GenesisHash
ToCBOR, Context -> GenesisHash -> IO (Maybe ThunkInfo)
Proxy GenesisHash -> String
(Context -> GenesisHash -> IO (Maybe ThunkInfo))
-> (Context -> GenesisHash -> IO (Maybe ThunkInfo))
-> (Proxy GenesisHash -> String)
-> NoThunks GenesisHash
forall a.
(Context -> a -> IO (Maybe ThunkInfo))
-> (Context -> a -> IO (Maybe ThunkInfo))
-> (Proxy a -> String)
-> NoThunks a
showTypeOf :: Proxy GenesisHash -> String
$cshowTypeOf :: Proxy GenesisHash -> String
wNoThunks :: Context -> GenesisHash -> IO (Maybe ThunkInfo)
$cwNoThunks :: Context -> GenesisHash -> IO (Maybe ThunkInfo)
noThunks :: Context -> GenesisHash -> IO (Maybe ThunkInfo)
$cnoThunks :: Context -> GenesisHash -> IO (Maybe ThunkInfo)
NoThunks)

deriving instance Show GenesisHash

-- Used for debugging purposes only
instance ToJSON GenesisHash