{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DerivingVia #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
module Cardano.Slotting.Block (
BlockNo (..),
)
where
import Cardano.Binary (FromCBOR (..), ToCBOR (..))
import Codec.Serialise (Serialise (..))
import Control.DeepSeq (NFData)
import Data.Aeson (FromJSON, ToJSON)
import Data.Word (Word64)
import GHC.Generics (Generic)
import NoThunks.Class (NoThunks)
import Quiet (Quiet (..))
newtype BlockNo = BlockNo {BlockNo -> Word64
unBlockNo :: Word64}
deriving stock (BlockNo -> BlockNo -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BlockNo -> BlockNo -> Bool
$c/= :: BlockNo -> BlockNo -> Bool
== :: BlockNo -> BlockNo -> Bool
$c== :: BlockNo -> BlockNo -> Bool
Eq, Eq BlockNo
BlockNo -> BlockNo -> Bool
BlockNo -> BlockNo -> Ordering
BlockNo -> BlockNo -> BlockNo
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
min :: BlockNo -> BlockNo -> BlockNo
$cmin :: BlockNo -> BlockNo -> BlockNo
max :: BlockNo -> BlockNo -> BlockNo
$cmax :: BlockNo -> BlockNo -> BlockNo
>= :: BlockNo -> BlockNo -> Bool
$c>= :: BlockNo -> BlockNo -> Bool
> :: BlockNo -> BlockNo -> Bool
$c> :: BlockNo -> BlockNo -> Bool
<= :: BlockNo -> BlockNo -> Bool
$c<= :: BlockNo -> BlockNo -> Bool
< :: BlockNo -> BlockNo -> Bool
$c< :: BlockNo -> BlockNo -> Bool
compare :: BlockNo -> BlockNo -> Ordering
$ccompare :: BlockNo -> BlockNo -> Ordering
Ord, forall x. Rep BlockNo x -> BlockNo
forall x. BlockNo -> Rep BlockNo x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep BlockNo x -> BlockNo
$cfrom :: forall x. BlockNo -> Rep BlockNo x
Generic)
deriving (Int -> BlockNo -> ShowS
[BlockNo] -> ShowS
BlockNo -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BlockNo] -> ShowS
$cshowList :: [BlockNo] -> ShowS
show :: BlockNo -> String
$cshow :: BlockNo -> String
showsPrec :: Int -> BlockNo -> ShowS
$cshowsPrec :: Int -> BlockNo -> ShowS
Show) via Quiet BlockNo
deriving newtype (Int -> BlockNo
BlockNo -> Int
BlockNo -> [BlockNo]
BlockNo -> BlockNo
BlockNo -> BlockNo -> [BlockNo]
BlockNo -> BlockNo -> BlockNo -> [BlockNo]
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
enumFromThenTo :: BlockNo -> BlockNo -> BlockNo -> [BlockNo]
$cenumFromThenTo :: BlockNo -> BlockNo -> BlockNo -> [BlockNo]
enumFromTo :: BlockNo -> BlockNo -> [BlockNo]
$cenumFromTo :: BlockNo -> BlockNo -> [BlockNo]
enumFromThen :: BlockNo -> BlockNo -> [BlockNo]
$cenumFromThen :: BlockNo -> BlockNo -> [BlockNo]
enumFrom :: BlockNo -> [BlockNo]
$cenumFrom :: BlockNo -> [BlockNo]
fromEnum :: BlockNo -> Int
$cfromEnum :: BlockNo -> Int
toEnum :: Int -> BlockNo
$ctoEnum :: Int -> BlockNo
pred :: BlockNo -> BlockNo
$cpred :: BlockNo -> BlockNo
succ :: BlockNo -> BlockNo
$csucc :: BlockNo -> BlockNo
Enum, BlockNo
forall a. a -> a -> Bounded a
maxBound :: BlockNo
$cmaxBound :: BlockNo
minBound :: BlockNo
$cminBound :: BlockNo
Bounded, Integer -> BlockNo
BlockNo -> BlockNo
BlockNo -> BlockNo -> BlockNo
forall a.
(a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (Integer -> a)
-> Num a
fromInteger :: Integer -> BlockNo
$cfromInteger :: Integer -> BlockNo
signum :: BlockNo -> BlockNo
$csignum :: BlockNo -> BlockNo
abs :: BlockNo -> BlockNo
$cabs :: BlockNo -> BlockNo
negate :: BlockNo -> BlockNo
$cnegate :: BlockNo -> BlockNo
* :: BlockNo -> BlockNo -> BlockNo
$c* :: BlockNo -> BlockNo -> BlockNo
- :: BlockNo -> BlockNo -> BlockNo
$c- :: BlockNo -> BlockNo -> BlockNo
+ :: BlockNo -> BlockNo -> BlockNo
$c+ :: BlockNo -> BlockNo -> BlockNo
Num, [BlockNo] -> Encoding
BlockNo -> Encoding
forall s. Decoder s [BlockNo]
forall s. Decoder s BlockNo
forall a.
(a -> Encoding)
-> (forall s. Decoder s a)
-> ([a] -> Encoding)
-> (forall s. Decoder s [a])
-> Serialise a
decodeList :: forall s. Decoder s [BlockNo]
$cdecodeList :: forall s. Decoder s [BlockNo]
encodeList :: [BlockNo] -> Encoding
$cencodeList :: [BlockNo] -> Encoding
decode :: forall s. Decoder s BlockNo
$cdecode :: forall s. Decoder s BlockNo
encode :: BlockNo -> Encoding
$cencode :: BlockNo -> Encoding
Serialise, Context -> BlockNo -> IO (Maybe ThunkInfo)
Proxy BlockNo -> String
forall a.
(Context -> a -> IO (Maybe ThunkInfo))
-> (Context -> a -> IO (Maybe ThunkInfo))
-> (Proxy a -> String)
-> NoThunks a
showTypeOf :: Proxy BlockNo -> String
$cshowTypeOf :: Proxy BlockNo -> String
wNoThunks :: Context -> BlockNo -> IO (Maybe ThunkInfo)
$cwNoThunks :: Context -> BlockNo -> IO (Maybe ThunkInfo)
noThunks :: Context -> BlockNo -> IO (Maybe ThunkInfo)
$cnoThunks :: Context -> BlockNo -> IO (Maybe ThunkInfo)
NoThunks, BlockNo -> ()
forall a. (a -> ()) -> NFData a
rnf :: BlockNo -> ()
$crnf :: BlockNo -> ()
NFData, [BlockNo] -> Encoding
[BlockNo] -> Value
BlockNo -> Bool
BlockNo -> Encoding
BlockNo -> Value
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> (a -> Bool)
-> ToJSON a
omitField :: BlockNo -> Bool
$comitField :: BlockNo -> Bool
toEncodingList :: [BlockNo] -> Encoding
$ctoEncodingList :: [BlockNo] -> Encoding
toJSONList :: [BlockNo] -> Value
$ctoJSONList :: [BlockNo] -> Value
toEncoding :: BlockNo -> Encoding
$ctoEncoding :: BlockNo -> Encoding
toJSON :: BlockNo -> Value
$ctoJSON :: BlockNo -> Value
ToJSON, Maybe BlockNo
Value -> Parser [BlockNo]
Value -> Parser BlockNo
forall a.
(Value -> Parser a)
-> (Value -> Parser [a]) -> Maybe a -> FromJSON a
omittedField :: Maybe BlockNo
$comittedField :: Maybe BlockNo
parseJSONList :: Value -> Parser [BlockNo]
$cparseJSONList :: Value -> Parser [BlockNo]
parseJSON :: Value -> Parser BlockNo
$cparseJSON :: Value -> Parser BlockNo
FromJSON)
instance ToCBOR BlockNo where
toCBOR :: BlockNo -> Encoding
toCBOR = forall a. Serialise a => a -> Encoding
encode
encodedSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size) -> Proxy BlockNo -> Size
encodedSizeExpr forall t. ToCBOR t => Proxy t -> Size
size = forall a.
ToCBOR a =>
(forall t. ToCBOR t => Proxy t -> Size) -> Proxy a -> Size
encodedSizeExpr forall t. ToCBOR t => Proxy t -> Size
size forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap BlockNo -> Word64
unBlockNo
instance FromCBOR BlockNo where
fromCBOR :: forall s. Decoder s BlockNo
fromCBOR = forall a s. Serialise a => Decoder s a
decode