{-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-} module Cardano.Chain.Common.BlockCount ( BlockCount (..), ) where import Cardano.Ledger.Binary ( DecCBOR (..), EncCBOR (..), FromCBOR (..), ToCBOR (..), fromByronCBOR, toByronCBOR, ) import Cardano.Prelude import Formatting.Buildable (Buildable) import NoThunks.Class (NoThunks (..)) newtype BlockCount = BlockCount { BlockCount -> Word64 unBlockCount :: Word64 } deriving (BlockCount -> BlockCount -> Bool (BlockCount -> BlockCount -> Bool) -> (BlockCount -> BlockCount -> Bool) -> Eq BlockCount forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a $c== :: BlockCount -> BlockCount -> Bool == :: BlockCount -> BlockCount -> Bool $c/= :: BlockCount -> BlockCount -> Bool /= :: BlockCount -> BlockCount -> Bool Eq, Eq BlockCount Eq BlockCount => (BlockCount -> BlockCount -> Ordering) -> (BlockCount -> BlockCount -> Bool) -> (BlockCount -> BlockCount -> Bool) -> (BlockCount -> BlockCount -> Bool) -> (BlockCount -> BlockCount -> Bool) -> (BlockCount -> BlockCount -> BlockCount) -> (BlockCount -> BlockCount -> BlockCount) -> Ord BlockCount BlockCount -> BlockCount -> Bool BlockCount -> BlockCount -> Ordering BlockCount -> BlockCount -> BlockCount forall a. Eq a => (a -> a -> Ordering) -> (a -> a -> Bool) -> (a -> a -> Bool) -> (a -> a -> Bool) -> (a -> a -> Bool) -> (a -> a -> a) -> (a -> a -> a) -> Ord a $ccompare :: BlockCount -> BlockCount -> Ordering compare :: BlockCount -> BlockCount -> Ordering $c< :: BlockCount -> BlockCount -> Bool < :: BlockCount -> BlockCount -> Bool $c<= :: BlockCount -> BlockCount -> Bool <= :: BlockCount -> BlockCount -> Bool $c> :: BlockCount -> BlockCount -> Bool > :: BlockCount -> BlockCount -> Bool $c>= :: BlockCount -> BlockCount -> Bool >= :: BlockCount -> BlockCount -> Bool $cmax :: BlockCount -> BlockCount -> BlockCount max :: BlockCount -> BlockCount -> BlockCount $cmin :: BlockCount -> BlockCount -> BlockCount min :: BlockCount -> BlockCount -> BlockCount Ord, Int -> BlockCount BlockCount -> Int BlockCount -> [BlockCount] BlockCount -> BlockCount BlockCount -> BlockCount -> [BlockCount] BlockCount -> BlockCount -> BlockCount -> [BlockCount] (BlockCount -> BlockCount) -> (BlockCount -> BlockCount) -> (Int -> BlockCount) -> (BlockCount -> Int) -> (BlockCount -> [BlockCount]) -> (BlockCount -> BlockCount -> [BlockCount]) -> (BlockCount -> BlockCount -> [BlockCount]) -> (BlockCount -> BlockCount -> BlockCount -> [BlockCount]) -> Enum BlockCount forall a. (a -> a) -> (a -> a) -> (Int -> a) -> (a -> Int) -> (a -> [a]) -> (a -> a -> [a]) -> (a -> a -> [a]) -> (a -> a -> a -> [a]) -> Enum a $csucc :: BlockCount -> BlockCount succ :: BlockCount -> BlockCount $cpred :: BlockCount -> BlockCount pred :: BlockCount -> BlockCount $ctoEnum :: Int -> BlockCount toEnum :: Int -> BlockCount $cfromEnum :: BlockCount -> Int fromEnum :: BlockCount -> Int $cenumFrom :: BlockCount -> [BlockCount] enumFrom :: BlockCount -> [BlockCount] $cenumFromThen :: BlockCount -> BlockCount -> [BlockCount] enumFromThen :: BlockCount -> BlockCount -> [BlockCount] $cenumFromTo :: BlockCount -> BlockCount -> [BlockCount] enumFromTo :: BlockCount -> BlockCount -> [BlockCount] $cenumFromThenTo :: BlockCount -> BlockCount -> BlockCount -> [BlockCount] enumFromThenTo :: BlockCount -> BlockCount -> BlockCount -> [BlockCount] Enum, ReadPrec [BlockCount] ReadPrec BlockCount Int -> ReadS BlockCount ReadS [BlockCount] (Int -> ReadS BlockCount) -> ReadS [BlockCount] -> ReadPrec BlockCount -> ReadPrec [BlockCount] -> Read BlockCount forall a. (Int -> ReadS a) -> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a $creadsPrec :: Int -> ReadS BlockCount readsPrec :: Int -> ReadS BlockCount $creadList :: ReadS [BlockCount] readList :: ReadS [BlockCount] $creadPrec :: ReadPrec BlockCount readPrec :: ReadPrec BlockCount $creadListPrec :: ReadPrec [BlockCount] readListPrec :: ReadPrec [BlockCount] Read, Int -> BlockCount -> ShowS [BlockCount] -> ShowS BlockCount -> String (Int -> BlockCount -> ShowS) -> (BlockCount -> String) -> ([BlockCount] -> ShowS) -> Show BlockCount forall a. (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a $cshowsPrec :: Int -> BlockCount -> ShowS showsPrec :: Int -> BlockCount -> ShowS $cshow :: BlockCount -> String show :: BlockCount -> String $cshowList :: [BlockCount] -> ShowS showList :: [BlockCount] -> ShowS Show, BlockCount -> Builder (BlockCount -> Builder) -> Buildable BlockCount forall p. (p -> Builder) -> Buildable p $cbuild :: BlockCount -> Builder build :: BlockCount -> Builder Buildable, (forall x. BlockCount -> Rep BlockCount x) -> (forall x. Rep BlockCount x -> BlockCount) -> Generic BlockCount forall x. Rep BlockCount x -> BlockCount forall x. BlockCount -> Rep BlockCount x forall a. (forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a $cfrom :: forall x. BlockCount -> Rep BlockCount x from :: forall x. BlockCount -> Rep BlockCount x $cto :: forall x. Rep BlockCount x -> BlockCount to :: forall x. Rep BlockCount x -> BlockCount Generic, BlockCount -> () (BlockCount -> ()) -> NFData BlockCount forall a. (a -> ()) -> NFData a $crnf :: BlockCount -> () rnf :: BlockCount -> () NFData, Context -> BlockCount -> IO (Maybe ThunkInfo) Proxy BlockCount -> String (Context -> BlockCount -> IO (Maybe ThunkInfo)) -> (Context -> BlockCount -> IO (Maybe ThunkInfo)) -> (Proxy BlockCount -> String) -> NoThunks BlockCount forall a. (Context -> a -> IO (Maybe ThunkInfo)) -> (Context -> a -> IO (Maybe ThunkInfo)) -> (Proxy a -> String) -> NoThunks a $cnoThunks :: Context -> BlockCount -> IO (Maybe ThunkInfo) noThunks :: Context -> BlockCount -> IO (Maybe ThunkInfo) $cwNoThunks :: Context -> BlockCount -> IO (Maybe ThunkInfo) wNoThunks :: Context -> BlockCount -> IO (Maybe ThunkInfo) $cshowTypeOf :: Proxy BlockCount -> String showTypeOf :: Proxy BlockCount -> String NoThunks) instance ToCBOR BlockCount where toCBOR :: BlockCount -> Encoding toCBOR = BlockCount -> Encoding forall a. EncCBOR a => a -> Encoding toByronCBOR instance FromCBOR BlockCount where fromCBOR :: forall s. Decoder s BlockCount fromCBOR = Decoder s BlockCount forall a s. DecCBOR a => Decoder s a fromByronCBOR instance EncCBOR BlockCount where encCBOR :: BlockCount -> Encoding encCBOR = Word64 -> Encoding forall a. EncCBOR a => a -> Encoding encCBOR (Word64 -> Encoding) -> (BlockCount -> Word64) -> BlockCount -> Encoding forall b c a. (b -> c) -> (a -> b) -> a -> c forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k). Category cat => cat b c -> cat a b -> cat a c . BlockCount -> Word64 unBlockCount encodedSizeExpr :: (forall t. EncCBOR t => Proxy t -> Size) -> Proxy BlockCount -> Size encodedSizeExpr forall t. EncCBOR t => Proxy t -> Size size Proxy BlockCount pxy = Proxy Word64 -> Size forall t. EncCBOR t => Proxy t -> Size size (BlockCount -> Word64 unBlockCount (BlockCount -> Word64) -> Proxy BlockCount -> Proxy Word64 forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> Proxy BlockCount pxy) instance DecCBOR BlockCount where decCBOR :: forall s. Decoder s BlockCount decCBOR = Word64 -> BlockCount BlockCount (Word64 -> BlockCount) -> Decoder s Word64 -> Decoder s BlockCount forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> Decoder s Word64 forall s. Decoder s Word64 forall a s. DecCBOR a => Decoder s a decCBOR