{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DeriveTraversable #-}
{-# LANGUAGE DerivingVia #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE OverloadedStrings #-}
module Cardano.Slotting.Slot (
SlotNo (..),
WithOrigin (..),
at,
origin,
fromWithOrigin,
withOrigin,
withOriginToMaybe,
withOriginFromMaybe,
EpochNo (..),
EpochSize (..),
EpochInterval (..),
binOpEpochNo,
addEpochInterval,
)
where
import Cardano.Binary (FromCBOR (..), ToCBOR (..))
import Codec.Serialise (Serialise (..))
import Control.DeepSeq (NFData (rnf))
import Data.Aeson (FromJSON (..), ToJSON (..), Value (String))
import Data.Typeable (Typeable)
import Data.Word (Word32, Word64)
import GHC.Generics (Generic)
import NoThunks.Class (NoThunks)
import Quiet (Quiet (..))
newtype SlotNo = SlotNo {SlotNo -> Word64
unSlotNo :: Word64}
deriving stock (SlotNo -> SlotNo -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SlotNo -> SlotNo -> Bool
$c/= :: SlotNo -> SlotNo -> Bool
== :: SlotNo -> SlotNo -> Bool
$c== :: SlotNo -> SlotNo -> Bool
Eq, Eq SlotNo
SlotNo -> SlotNo -> Bool
SlotNo -> SlotNo -> Ordering
SlotNo -> SlotNo -> SlotNo
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 :: SlotNo -> SlotNo -> SlotNo
$cmin :: SlotNo -> SlotNo -> SlotNo
max :: SlotNo -> SlotNo -> SlotNo
$cmax :: SlotNo -> SlotNo -> SlotNo
>= :: SlotNo -> SlotNo -> Bool
$c>= :: SlotNo -> SlotNo -> Bool
> :: SlotNo -> SlotNo -> Bool
$c> :: SlotNo -> SlotNo -> Bool
<= :: SlotNo -> SlotNo -> Bool
$c<= :: SlotNo -> SlotNo -> Bool
< :: SlotNo -> SlotNo -> Bool
$c< :: SlotNo -> SlotNo -> Bool
compare :: SlotNo -> SlotNo -> Ordering
$ccompare :: SlotNo -> SlotNo -> Ordering
Ord, forall x. Rep SlotNo x -> SlotNo
forall x. SlotNo -> Rep SlotNo x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SlotNo x -> SlotNo
$cfrom :: forall x. SlotNo -> Rep SlotNo x
Generic)
deriving (Int -> SlotNo -> ShowS
[SlotNo] -> ShowS
SlotNo -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SlotNo] -> ShowS
$cshowList :: [SlotNo] -> ShowS
show :: SlotNo -> String
$cshow :: SlotNo -> String
showsPrec :: Int -> SlotNo -> ShowS
$cshowsPrec :: Int -> SlotNo -> ShowS
Show) via Quiet SlotNo
deriving newtype (Int -> SlotNo
SlotNo -> Int
SlotNo -> [SlotNo]
SlotNo -> SlotNo
SlotNo -> SlotNo -> [SlotNo]
SlotNo -> SlotNo -> SlotNo -> [SlotNo]
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 :: SlotNo -> SlotNo -> SlotNo -> [SlotNo]
$cenumFromThenTo :: SlotNo -> SlotNo -> SlotNo -> [SlotNo]
enumFromTo :: SlotNo -> SlotNo -> [SlotNo]
$cenumFromTo :: SlotNo -> SlotNo -> [SlotNo]
enumFromThen :: SlotNo -> SlotNo -> [SlotNo]
$cenumFromThen :: SlotNo -> SlotNo -> [SlotNo]
enumFrom :: SlotNo -> [SlotNo]
$cenumFrom :: SlotNo -> [SlotNo]
fromEnum :: SlotNo -> Int
$cfromEnum :: SlotNo -> Int
toEnum :: Int -> SlotNo
$ctoEnum :: Int -> SlotNo
pred :: SlotNo -> SlotNo
$cpred :: SlotNo -> SlotNo
succ :: SlotNo -> SlotNo
$csucc :: SlotNo -> SlotNo
Enum, SlotNo
forall a. a -> a -> Bounded a
maxBound :: SlotNo
$cmaxBound :: SlotNo
minBound :: SlotNo
$cminBound :: SlotNo
Bounded, Integer -> SlotNo
SlotNo -> SlotNo
SlotNo -> SlotNo -> SlotNo
forall a.
(a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (Integer -> a)
-> Num a
fromInteger :: Integer -> SlotNo
$cfromInteger :: Integer -> SlotNo
signum :: SlotNo -> SlotNo
$csignum :: SlotNo -> SlotNo
abs :: SlotNo -> SlotNo
$cabs :: SlotNo -> SlotNo
negate :: SlotNo -> SlotNo
$cnegate :: SlotNo -> SlotNo
* :: SlotNo -> SlotNo -> SlotNo
$c* :: SlotNo -> SlotNo -> SlotNo
- :: SlotNo -> SlotNo -> SlotNo
$c- :: SlotNo -> SlotNo -> SlotNo
+ :: SlotNo -> SlotNo -> SlotNo
$c+ :: SlotNo -> SlotNo -> SlotNo
Num, SlotNo -> ()
forall a. (a -> ()) -> NFData a
rnf :: SlotNo -> ()
$crnf :: SlotNo -> ()
NFData, [SlotNo] -> Encoding
SlotNo -> Encoding
forall s. Decoder s [SlotNo]
forall s. Decoder s SlotNo
forall a.
(a -> Encoding)
-> (forall s. Decoder s a)
-> ([a] -> Encoding)
-> (forall s. Decoder s [a])
-> Serialise a
decodeList :: forall s. Decoder s [SlotNo]
$cdecodeList :: forall s. Decoder s [SlotNo]
encodeList :: [SlotNo] -> Encoding
$cencodeList :: [SlotNo] -> Encoding
decode :: forall s. Decoder s SlotNo
$cdecode :: forall s. Decoder s SlotNo
encode :: SlotNo -> Encoding
$cencode :: SlotNo -> Encoding
Serialise, Context -> SlotNo -> IO (Maybe ThunkInfo)
Proxy SlotNo -> String
forall a.
(Context -> a -> IO (Maybe ThunkInfo))
-> (Context -> a -> IO (Maybe ThunkInfo))
-> (Proxy a -> String)
-> NoThunks a
showTypeOf :: Proxy SlotNo -> String
$cshowTypeOf :: Proxy SlotNo -> String
wNoThunks :: Context -> SlotNo -> IO (Maybe ThunkInfo)
$cwNoThunks :: Context -> SlotNo -> IO (Maybe ThunkInfo)
noThunks :: Context -> SlotNo -> IO (Maybe ThunkInfo)
$cnoThunks :: Context -> SlotNo -> IO (Maybe ThunkInfo)
NoThunks, [SlotNo] -> Encoding
[SlotNo] -> Value
SlotNo -> Bool
SlotNo -> Encoding
SlotNo -> Value
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> (a -> Bool)
-> ToJSON a
omitField :: SlotNo -> Bool
$comitField :: SlotNo -> Bool
toEncodingList :: [SlotNo] -> Encoding
$ctoEncodingList :: [SlotNo] -> Encoding
toJSONList :: [SlotNo] -> Value
$ctoJSONList :: [SlotNo] -> Value
toEncoding :: SlotNo -> Encoding
$ctoEncoding :: SlotNo -> Encoding
toJSON :: SlotNo -> Value
$ctoJSON :: SlotNo -> Value
ToJSON, Maybe SlotNo
Value -> Parser [SlotNo]
Value -> Parser SlotNo
forall a.
(Value -> Parser a)
-> (Value -> Parser [a]) -> Maybe a -> FromJSON a
omittedField :: Maybe SlotNo
$comittedField :: Maybe SlotNo
parseJSONList :: Value -> Parser [SlotNo]
$cparseJSONList :: Value -> Parser [SlotNo]
parseJSON :: Value -> Parser SlotNo
$cparseJSON :: Value -> Parser SlotNo
FromJSON)
instance ToCBOR SlotNo where
toCBOR :: SlotNo -> Encoding
toCBOR = forall a. Serialise a => a -> Encoding
encode
encodedSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size) -> Proxy SlotNo -> 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 SlotNo -> Word64
unSlotNo
instance FromCBOR SlotNo where
fromCBOR :: forall s. Decoder s SlotNo
fromCBOR = forall a s. Serialise a => Decoder s a
decode
data WithOrigin t = Origin | At !t
deriving
( WithOrigin t -> WithOrigin t -> Bool
forall t. Eq t => WithOrigin t -> WithOrigin t -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: WithOrigin t -> WithOrigin t -> Bool
$c/= :: forall t. Eq t => WithOrigin t -> WithOrigin t -> Bool
== :: WithOrigin t -> WithOrigin t -> Bool
$c== :: forall t. Eq t => WithOrigin t -> WithOrigin t -> Bool
Eq
, WithOrigin t -> WithOrigin t -> Bool
WithOrigin t -> WithOrigin t -> Ordering
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
forall {t}. Ord t => Eq (WithOrigin t)
forall t. Ord t => WithOrigin t -> WithOrigin t -> Bool
forall t. Ord t => WithOrigin t -> WithOrigin t -> Ordering
forall t. Ord t => WithOrigin t -> WithOrigin t -> WithOrigin t
min :: WithOrigin t -> WithOrigin t -> WithOrigin t
$cmin :: forall t. Ord t => WithOrigin t -> WithOrigin t -> WithOrigin t
max :: WithOrigin t -> WithOrigin t -> WithOrigin t
$cmax :: forall t. Ord t => WithOrigin t -> WithOrigin t -> WithOrigin t
>= :: WithOrigin t -> WithOrigin t -> Bool
$c>= :: forall t. Ord t => WithOrigin t -> WithOrigin t -> Bool
> :: WithOrigin t -> WithOrigin t -> Bool
$c> :: forall t. Ord t => WithOrigin t -> WithOrigin t -> Bool
<= :: WithOrigin t -> WithOrigin t -> Bool
$c<= :: forall t. Ord t => WithOrigin t -> WithOrigin t -> Bool
< :: WithOrigin t -> WithOrigin t -> Bool
$c< :: forall t. Ord t => WithOrigin t -> WithOrigin t -> Bool
compare :: WithOrigin t -> WithOrigin t -> Ordering
$ccompare :: forall t. Ord t => WithOrigin t -> WithOrigin t -> Ordering
Ord
, Int -> WithOrigin t -> ShowS
forall t. Show t => Int -> WithOrigin t -> ShowS
forall t. Show t => [WithOrigin t] -> ShowS
forall t. Show t => WithOrigin t -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [WithOrigin t] -> ShowS
$cshowList :: forall t. Show t => [WithOrigin t] -> ShowS
show :: WithOrigin t -> String
$cshow :: forall t. Show t => WithOrigin t -> String
showsPrec :: Int -> WithOrigin t -> ShowS
$cshowsPrec :: forall t. Show t => Int -> WithOrigin t -> ShowS
Show
, forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall t x. Rep (WithOrigin t) x -> WithOrigin t
forall t x. WithOrigin t -> Rep (WithOrigin t) x
$cto :: forall t x. Rep (WithOrigin t) x -> WithOrigin t
$cfrom :: forall t x. WithOrigin t -> Rep (WithOrigin t) x
Generic
, forall a b. a -> WithOrigin b -> WithOrigin a
forall a b. (a -> b) -> WithOrigin a -> WithOrigin b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: forall a b. a -> WithOrigin b -> WithOrigin a
$c<$ :: forall a b. a -> WithOrigin b -> WithOrigin a
fmap :: forall a b. (a -> b) -> WithOrigin a -> WithOrigin b
$cfmap :: forall a b. (a -> b) -> WithOrigin a -> WithOrigin b
Functor
, forall a. Eq a => a -> WithOrigin a -> Bool
forall a. Num a => WithOrigin a -> a
forall a. Ord a => WithOrigin a -> a
forall m. Monoid m => WithOrigin m -> m
forall a. WithOrigin a -> Bool
forall a. WithOrigin a -> Int
forall a. WithOrigin a -> [a]
forall a. (a -> a -> a) -> WithOrigin a -> a
forall m a. Monoid m => (a -> m) -> WithOrigin a -> m
forall b a. (b -> a -> b) -> b -> WithOrigin a -> b
forall a b. (a -> b -> b) -> b -> WithOrigin a -> b
forall (t :: * -> *).
(forall m. Monoid m => t m -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. t a -> [a])
-> (forall a. t a -> Bool)
-> (forall a. t a -> Int)
-> (forall a. Eq a => a -> t a -> Bool)
-> (forall a. Ord a => t a -> a)
-> (forall a. Ord a => t a -> a)
-> (forall a. Num a => t a -> a)
-> (forall a. Num a => t a -> a)
-> Foldable t
product :: forall a. Num a => WithOrigin a -> a
$cproduct :: forall a. Num a => WithOrigin a -> a
sum :: forall a. Num a => WithOrigin a -> a
$csum :: forall a. Num a => WithOrigin a -> a
minimum :: forall a. Ord a => WithOrigin a -> a
$cminimum :: forall a. Ord a => WithOrigin a -> a
maximum :: forall a. Ord a => WithOrigin a -> a
$cmaximum :: forall a. Ord a => WithOrigin a -> a
elem :: forall a. Eq a => a -> WithOrigin a -> Bool
$celem :: forall a. Eq a => a -> WithOrigin a -> Bool
length :: forall a. WithOrigin a -> Int
$clength :: forall a. WithOrigin a -> Int
null :: forall a. WithOrigin a -> Bool
$cnull :: forall a. WithOrigin a -> Bool
toList :: forall a. WithOrigin a -> [a]
$ctoList :: forall a. WithOrigin a -> [a]
foldl1 :: forall a. (a -> a -> a) -> WithOrigin a -> a
$cfoldl1 :: forall a. (a -> a -> a) -> WithOrigin a -> a
foldr1 :: forall a. (a -> a -> a) -> WithOrigin a -> a
$cfoldr1 :: forall a. (a -> a -> a) -> WithOrigin a -> a
foldl' :: forall b a. (b -> a -> b) -> b -> WithOrigin a -> b
$cfoldl' :: forall b a. (b -> a -> b) -> b -> WithOrigin a -> b
foldl :: forall b a. (b -> a -> b) -> b -> WithOrigin a -> b
$cfoldl :: forall b a. (b -> a -> b) -> b -> WithOrigin a -> b
foldr' :: forall a b. (a -> b -> b) -> b -> WithOrigin a -> b
$cfoldr' :: forall a b. (a -> b -> b) -> b -> WithOrigin a -> b
foldr :: forall a b. (a -> b -> b) -> b -> WithOrigin a -> b
$cfoldr :: forall a b. (a -> b -> b) -> b -> WithOrigin a -> b
foldMap' :: forall m a. Monoid m => (a -> m) -> WithOrigin a -> m
$cfoldMap' :: forall m a. Monoid m => (a -> m) -> WithOrigin a -> m
foldMap :: forall m a. Monoid m => (a -> m) -> WithOrigin a -> m
$cfoldMap :: forall m a. Monoid m => (a -> m) -> WithOrigin a -> m
fold :: forall m. Monoid m => WithOrigin m -> m
$cfold :: forall m. Monoid m => WithOrigin m -> m
Foldable
, Functor WithOrigin
Foldable WithOrigin
forall (t :: * -> *).
Functor t
-> Foldable t
-> (forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> t a -> f (t b))
-> (forall (f :: * -> *) a. Applicative f => t (f a) -> f (t a))
-> (forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> t a -> m (t b))
-> (forall (m :: * -> *) a. Monad m => t (m a) -> m (t a))
-> Traversable t
forall (m :: * -> *) a.
Monad m =>
WithOrigin (m a) -> m (WithOrigin a)
forall (f :: * -> *) a.
Applicative f =>
WithOrigin (f a) -> f (WithOrigin a)
forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> WithOrigin a -> m (WithOrigin b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> WithOrigin a -> f (WithOrigin b)
sequence :: forall (m :: * -> *) a.
Monad m =>
WithOrigin (m a) -> m (WithOrigin a)
$csequence :: forall (m :: * -> *) a.
Monad m =>
WithOrigin (m a) -> m (WithOrigin a)
mapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> WithOrigin a -> m (WithOrigin b)
$cmapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> WithOrigin a -> m (WithOrigin b)
sequenceA :: forall (f :: * -> *) a.
Applicative f =>
WithOrigin (f a) -> f (WithOrigin a)
$csequenceA :: forall (f :: * -> *) a.
Applicative f =>
WithOrigin (f a) -> f (WithOrigin a)
traverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> WithOrigin a -> f (WithOrigin b)
$ctraverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> WithOrigin a -> f (WithOrigin b)
Traversable
, forall t. Serialise t => [WithOrigin t] -> Encoding
forall t. Serialise t => WithOrigin t -> Encoding
forall t s. Serialise t => Decoder s [WithOrigin t]
forall t s. Serialise t => Decoder s (WithOrigin t)
forall a.
(a -> Encoding)
-> (forall s. Decoder s a)
-> ([a] -> Encoding)
-> (forall s. Decoder s [a])
-> Serialise a
decodeList :: forall s. Decoder s [WithOrigin t]
$cdecodeList :: forall t s. Serialise t => Decoder s [WithOrigin t]
encodeList :: [WithOrigin t] -> Encoding
$cencodeList :: forall t. Serialise t => [WithOrigin t] -> Encoding
decode :: forall s. Decoder s (WithOrigin t)
$cdecode :: forall t s. Serialise t => Decoder s (WithOrigin t)
encode :: WithOrigin t -> Encoding
$cencode :: forall t. Serialise t => WithOrigin t -> Encoding
Serialise
, forall t.
NoThunks t =>
Context -> WithOrigin t -> IO (Maybe ThunkInfo)
forall t. NoThunks t => Proxy (WithOrigin t) -> String
forall a.
(Context -> a -> IO (Maybe ThunkInfo))
-> (Context -> a -> IO (Maybe ThunkInfo))
-> (Proxy a -> String)
-> NoThunks a
showTypeOf :: Proxy (WithOrigin t) -> String
$cshowTypeOf :: forall t. NoThunks t => Proxy (WithOrigin t) -> String
wNoThunks :: Context -> WithOrigin t -> IO (Maybe ThunkInfo)
$cwNoThunks :: forall t.
NoThunks t =>
Context -> WithOrigin t -> IO (Maybe ThunkInfo)
noThunks :: Context -> WithOrigin t -> IO (Maybe ThunkInfo)
$cnoThunks :: forall t.
NoThunks t =>
Context -> WithOrigin t -> IO (Maybe ThunkInfo)
NoThunks
)
instance (Serialise t, Typeable t) => ToCBOR (WithOrigin t) where
toCBOR :: WithOrigin t -> Encoding
toCBOR = forall a. Serialise a => a -> Encoding
encode
instance (Serialise t, Typeable t) => FromCBOR (WithOrigin t) where
fromCBOR :: forall s. Decoder s (WithOrigin t)
fromCBOR = forall a s. Serialise a => Decoder s a
decode
instance Bounded t => Bounded (WithOrigin t) where
minBound :: WithOrigin t
minBound = forall t. WithOrigin t
Origin
maxBound :: WithOrigin t
maxBound = forall t. t -> WithOrigin t
At forall a. Bounded a => a
maxBound
instance NFData a => NFData (WithOrigin a) where
rnf :: WithOrigin a -> ()
rnf WithOrigin a
Origin = ()
rnf (At a
t) = forall a. NFData a => a -> ()
rnf a
t
instance ToJSON a => ToJSON (WithOrigin a) where
toJSON :: WithOrigin a -> Value
toJSON = \case
WithOrigin a
Origin -> Text -> Value
String Text
"origin"
At a
n -> forall a. ToJSON a => a -> Value
toJSON a
n
instance FromJSON a => FromJSON (WithOrigin a) where
parseJSON :: Value -> Parser (WithOrigin a)
parseJSON = \case
String Text
"origin" -> forall (f :: * -> *) a. Applicative f => a -> f a
pure forall t. WithOrigin t
Origin
Value
value -> forall t. t -> WithOrigin t
At forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall a. FromJSON a => Value -> Parser a
parseJSON Value
value
at :: t -> WithOrigin t
at :: forall t. t -> WithOrigin t
at = forall t. t -> WithOrigin t
At
origin :: WithOrigin t
origin :: forall t. WithOrigin t
origin = forall t. WithOrigin t
Origin
fromWithOrigin :: t -> WithOrigin t -> t
fromWithOrigin :: forall t. t -> WithOrigin t -> t
fromWithOrigin t
t WithOrigin t
Origin = t
t
fromWithOrigin t
_ (At t
t) = t
t
withOrigin :: b -> (t -> b) -> WithOrigin t -> b
withOrigin :: forall b t. b -> (t -> b) -> WithOrigin t -> b
withOrigin b
a t -> b
_ WithOrigin t
Origin = b
a
withOrigin b
_ t -> b
f (At t
t) = t -> b
f t
t
withOriginToMaybe :: WithOrigin t -> Maybe t
withOriginToMaybe :: forall t. WithOrigin t -> Maybe t
withOriginToMaybe WithOrigin t
Origin = forall a. Maybe a
Nothing
withOriginToMaybe (At t
t) = forall a. a -> Maybe a
Just t
t
withOriginFromMaybe :: Maybe t -> WithOrigin t
withOriginFromMaybe :: forall t. Maybe t -> WithOrigin t
withOriginFromMaybe Maybe t
Nothing = forall t. WithOrigin t
Origin
withOriginFromMaybe (Just t
t) = forall t. t -> WithOrigin t
At t
t
newtype EpochNo = EpochNo {EpochNo -> Word64
unEpochNo :: Word64}
deriving stock (EpochNo -> EpochNo -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EpochNo -> EpochNo -> Bool
$c/= :: EpochNo -> EpochNo -> Bool
== :: EpochNo -> EpochNo -> Bool
$c== :: EpochNo -> EpochNo -> Bool
Eq, Eq EpochNo
EpochNo -> EpochNo -> Bool
EpochNo -> EpochNo -> Ordering
EpochNo -> EpochNo -> EpochNo
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 :: EpochNo -> EpochNo -> EpochNo
$cmin :: EpochNo -> EpochNo -> EpochNo
max :: EpochNo -> EpochNo -> EpochNo
$cmax :: EpochNo -> EpochNo -> EpochNo
>= :: EpochNo -> EpochNo -> Bool
$c>= :: EpochNo -> EpochNo -> Bool
> :: EpochNo -> EpochNo -> Bool
$c> :: EpochNo -> EpochNo -> Bool
<= :: EpochNo -> EpochNo -> Bool
$c<= :: EpochNo -> EpochNo -> Bool
< :: EpochNo -> EpochNo -> Bool
$c< :: EpochNo -> EpochNo -> Bool
compare :: EpochNo -> EpochNo -> Ordering
$ccompare :: EpochNo -> EpochNo -> Ordering
Ord, forall x. Rep EpochNo x -> EpochNo
forall x. EpochNo -> Rep EpochNo x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep EpochNo x -> EpochNo
$cfrom :: forall x. EpochNo -> Rep EpochNo x
Generic)
deriving (Int -> EpochNo -> ShowS
[EpochNo] -> ShowS
EpochNo -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EpochNo] -> ShowS
$cshowList :: [EpochNo] -> ShowS
show :: EpochNo -> String
$cshow :: EpochNo -> String
showsPrec :: Int -> EpochNo -> ShowS
$cshowsPrec :: Int -> EpochNo -> ShowS
Show) via Quiet EpochNo
deriving newtype (Int -> EpochNo
EpochNo -> Int
EpochNo -> [EpochNo]
EpochNo -> EpochNo
EpochNo -> EpochNo -> [EpochNo]
EpochNo -> EpochNo -> EpochNo -> [EpochNo]
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 :: EpochNo -> EpochNo -> EpochNo -> [EpochNo]
$cenumFromThenTo :: EpochNo -> EpochNo -> EpochNo -> [EpochNo]
enumFromTo :: EpochNo -> EpochNo -> [EpochNo]
$cenumFromTo :: EpochNo -> EpochNo -> [EpochNo]
enumFromThen :: EpochNo -> EpochNo -> [EpochNo]
$cenumFromThen :: EpochNo -> EpochNo -> [EpochNo]
enumFrom :: EpochNo -> [EpochNo]
$cenumFrom :: EpochNo -> [EpochNo]
fromEnum :: EpochNo -> Int
$cfromEnum :: EpochNo -> Int
toEnum :: Int -> EpochNo
$ctoEnum :: Int -> EpochNo
pred :: EpochNo -> EpochNo
$cpred :: EpochNo -> EpochNo
succ :: EpochNo -> EpochNo
$csucc :: EpochNo -> EpochNo
Enum, [EpochNo] -> Encoding
EpochNo -> Encoding
forall s. Decoder s [EpochNo]
forall s. Decoder s EpochNo
forall a.
(a -> Encoding)
-> (forall s. Decoder s a)
-> ([a] -> Encoding)
-> (forall s. Decoder s [a])
-> Serialise a
decodeList :: forall s. Decoder s [EpochNo]
$cdecodeList :: forall s. Decoder s [EpochNo]
encodeList :: [EpochNo] -> Encoding
$cencodeList :: [EpochNo] -> Encoding
decode :: forall s. Decoder s EpochNo
$cdecode :: forall s. Decoder s EpochNo
encode :: EpochNo -> Encoding
$cencode :: EpochNo -> Encoding
Serialise, Typeable EpochNo
EpochNo -> Encoding
(forall t. ToCBOR t => Proxy t -> Size) -> Proxy [EpochNo] -> Size
(forall t. ToCBOR t => Proxy t -> Size) -> Proxy EpochNo -> 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 [EpochNo] -> Size
$cencodedListSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size) -> Proxy [EpochNo] -> Size
encodedSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size) -> Proxy EpochNo -> Size
$cencodedSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size) -> Proxy EpochNo -> Size
toCBOR :: EpochNo -> Encoding
$ctoCBOR :: EpochNo -> Encoding
ToCBOR, Typeable EpochNo
Proxy EpochNo -> Text
forall s. Decoder s EpochNo
forall a.
Typeable a
-> (forall s. Decoder s a) -> (Proxy a -> Text) -> FromCBOR a
label :: Proxy EpochNo -> Text
$clabel :: Proxy EpochNo -> Text
fromCBOR :: forall s. Decoder s EpochNo
$cfromCBOR :: forall s. Decoder s EpochNo
FromCBOR, Context -> EpochNo -> IO (Maybe ThunkInfo)
Proxy EpochNo -> String
forall a.
(Context -> a -> IO (Maybe ThunkInfo))
-> (Context -> a -> IO (Maybe ThunkInfo))
-> (Proxy a -> String)
-> NoThunks a
showTypeOf :: Proxy EpochNo -> String
$cshowTypeOf :: Proxy EpochNo -> String
wNoThunks :: Context -> EpochNo -> IO (Maybe ThunkInfo)
$cwNoThunks :: Context -> EpochNo -> IO (Maybe ThunkInfo)
noThunks :: Context -> EpochNo -> IO (Maybe ThunkInfo)
$cnoThunks :: Context -> EpochNo -> IO (Maybe ThunkInfo)
NoThunks, [EpochNo] -> Encoding
[EpochNo] -> Value
EpochNo -> Bool
EpochNo -> Encoding
EpochNo -> Value
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> (a -> Bool)
-> ToJSON a
omitField :: EpochNo -> Bool
$comitField :: EpochNo -> Bool
toEncodingList :: [EpochNo] -> Encoding
$ctoEncodingList :: [EpochNo] -> Encoding
toJSONList :: [EpochNo] -> Value
$ctoJSONList :: [EpochNo] -> Value
toEncoding :: EpochNo -> Encoding
$ctoEncoding :: EpochNo -> Encoding
toJSON :: EpochNo -> Value
$ctoJSON :: EpochNo -> Value
ToJSON, Maybe EpochNo
Value -> Parser [EpochNo]
Value -> Parser EpochNo
forall a.
(Value -> Parser a)
-> (Value -> Parser [a]) -> Maybe a -> FromJSON a
omittedField :: Maybe EpochNo
$comittedField :: Maybe EpochNo
parseJSONList :: Value -> Parser [EpochNo]
$cparseJSONList :: Value -> Parser [EpochNo]
parseJSON :: Value -> Parser EpochNo
$cparseJSON :: Value -> Parser EpochNo
FromJSON, EpochNo -> ()
forall a. (a -> ()) -> NFData a
rnf :: EpochNo -> ()
$crnf :: EpochNo -> ()
NFData)
newtype EpochSize = EpochSize {EpochSize -> Word64
unEpochSize :: Word64}
deriving stock (EpochSize -> EpochSize -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EpochSize -> EpochSize -> Bool
$c/= :: EpochSize -> EpochSize -> Bool
== :: EpochSize -> EpochSize -> Bool
$c== :: EpochSize -> EpochSize -> Bool
Eq, Eq EpochSize
EpochSize -> EpochSize -> Bool
EpochSize -> EpochSize -> Ordering
EpochSize -> EpochSize -> EpochSize
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 :: EpochSize -> EpochSize -> EpochSize
$cmin :: EpochSize -> EpochSize -> EpochSize
max :: EpochSize -> EpochSize -> EpochSize
$cmax :: EpochSize -> EpochSize -> EpochSize
>= :: EpochSize -> EpochSize -> Bool
$c>= :: EpochSize -> EpochSize -> Bool
> :: EpochSize -> EpochSize -> Bool
$c> :: EpochSize -> EpochSize -> Bool
<= :: EpochSize -> EpochSize -> Bool
$c<= :: EpochSize -> EpochSize -> Bool
< :: EpochSize -> EpochSize -> Bool
$c< :: EpochSize -> EpochSize -> Bool
compare :: EpochSize -> EpochSize -> Ordering
$ccompare :: EpochSize -> EpochSize -> Ordering
Ord, forall x. Rep EpochSize x -> EpochSize
forall x. EpochSize -> Rep EpochSize x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep EpochSize x -> EpochSize
$cfrom :: forall x. EpochSize -> Rep EpochSize x
Generic)
deriving (Int -> EpochSize -> ShowS
[EpochSize] -> ShowS
EpochSize -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EpochSize] -> ShowS
$cshowList :: [EpochSize] -> ShowS
show :: EpochSize -> String
$cshow :: EpochSize -> String
showsPrec :: Int -> EpochSize -> ShowS
$cshowsPrec :: Int -> EpochSize -> ShowS
Show) via Quiet EpochSize
deriving newtype (Int -> EpochSize
EpochSize -> Int
EpochSize -> [EpochSize]
EpochSize -> EpochSize
EpochSize -> EpochSize -> [EpochSize]
EpochSize -> EpochSize -> EpochSize -> [EpochSize]
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 :: EpochSize -> EpochSize -> EpochSize -> [EpochSize]
$cenumFromThenTo :: EpochSize -> EpochSize -> EpochSize -> [EpochSize]
enumFromTo :: EpochSize -> EpochSize -> [EpochSize]
$cenumFromTo :: EpochSize -> EpochSize -> [EpochSize]
enumFromThen :: EpochSize -> EpochSize -> [EpochSize]
$cenumFromThen :: EpochSize -> EpochSize -> [EpochSize]
enumFrom :: EpochSize -> [EpochSize]
$cenumFrom :: EpochSize -> [EpochSize]
fromEnum :: EpochSize -> Int
$cfromEnum :: EpochSize -> Int
toEnum :: Int -> EpochSize
$ctoEnum :: Int -> EpochSize
pred :: EpochSize -> EpochSize
$cpred :: EpochSize -> EpochSize
succ :: EpochSize -> EpochSize
$csucc :: EpochSize -> EpochSize
Enum, Typeable EpochSize
EpochSize -> Encoding
(forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [EpochSize] -> Size
(forall t. ToCBOR t => Proxy t -> Size) -> Proxy EpochSize -> 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 [EpochSize] -> Size
$cencodedListSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [EpochSize] -> Size
encodedSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size) -> Proxy EpochSize -> Size
$cencodedSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size) -> Proxy EpochSize -> Size
toCBOR :: EpochSize -> Encoding
$ctoCBOR :: EpochSize -> Encoding
ToCBOR, Typeable EpochSize
Proxy EpochSize -> Text
forall s. Decoder s EpochSize
forall a.
Typeable a
-> (forall s. Decoder s a) -> (Proxy a -> Text) -> FromCBOR a
label :: Proxy EpochSize -> Text
$clabel :: Proxy EpochSize -> Text
fromCBOR :: forall s. Decoder s EpochSize
$cfromCBOR :: forall s. Decoder s EpochSize
FromCBOR, Context -> EpochSize -> IO (Maybe ThunkInfo)
Proxy EpochSize -> String
forall a.
(Context -> a -> IO (Maybe ThunkInfo))
-> (Context -> a -> IO (Maybe ThunkInfo))
-> (Proxy a -> String)
-> NoThunks a
showTypeOf :: Proxy EpochSize -> String
$cshowTypeOf :: Proxy EpochSize -> String
wNoThunks :: Context -> EpochSize -> IO (Maybe ThunkInfo)
$cwNoThunks :: Context -> EpochSize -> IO (Maybe ThunkInfo)
noThunks :: Context -> EpochSize -> IO (Maybe ThunkInfo)
$cnoThunks :: Context -> EpochSize -> IO (Maybe ThunkInfo)
NoThunks, [EpochSize] -> Encoding
[EpochSize] -> Value
EpochSize -> Bool
EpochSize -> Encoding
EpochSize -> Value
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> (a -> Bool)
-> ToJSON a
omitField :: EpochSize -> Bool
$comitField :: EpochSize -> Bool
toEncodingList :: [EpochSize] -> Encoding
$ctoEncodingList :: [EpochSize] -> Encoding
toJSONList :: [EpochSize] -> Value
$ctoJSONList :: [EpochSize] -> Value
toEncoding :: EpochSize -> Encoding
$ctoEncoding :: EpochSize -> Encoding
toJSON :: EpochSize -> Value
$ctoJSON :: EpochSize -> Value
ToJSON, Maybe EpochSize
Value -> Parser [EpochSize]
Value -> Parser EpochSize
forall a.
(Value -> Parser a)
-> (Value -> Parser [a]) -> Maybe a -> FromJSON a
omittedField :: Maybe EpochSize
$comittedField :: Maybe EpochSize
parseJSONList :: Value -> Parser [EpochSize]
$cparseJSONList :: Value -> Parser [EpochSize]
parseJSON :: Value -> Parser EpochSize
$cparseJSON :: Value -> Parser EpochSize
FromJSON, EpochSize -> ()
forall a. (a -> ()) -> NFData a
rnf :: EpochSize -> ()
$crnf :: EpochSize -> ()
NFData)
newtype EpochInterval = EpochInterval
{ EpochInterval -> Word32
unEpochInterval :: Word32
}
deriving (EpochInterval -> EpochInterval -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EpochInterval -> EpochInterval -> Bool
$c/= :: EpochInterval -> EpochInterval -> Bool
== :: EpochInterval -> EpochInterval -> Bool
$c== :: EpochInterval -> EpochInterval -> Bool
Eq, Eq EpochInterval
EpochInterval -> EpochInterval -> Bool
EpochInterval -> EpochInterval -> Ordering
EpochInterval -> EpochInterval -> EpochInterval
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 :: EpochInterval -> EpochInterval -> EpochInterval
$cmin :: EpochInterval -> EpochInterval -> EpochInterval
max :: EpochInterval -> EpochInterval -> EpochInterval
$cmax :: EpochInterval -> EpochInterval -> EpochInterval
>= :: EpochInterval -> EpochInterval -> Bool
$c>= :: EpochInterval -> EpochInterval -> Bool
> :: EpochInterval -> EpochInterval -> Bool
$c> :: EpochInterval -> EpochInterval -> Bool
<= :: EpochInterval -> EpochInterval -> Bool
$c<= :: EpochInterval -> EpochInterval -> Bool
< :: EpochInterval -> EpochInterval -> Bool
$c< :: EpochInterval -> EpochInterval -> Bool
compare :: EpochInterval -> EpochInterval -> Ordering
$ccompare :: EpochInterval -> EpochInterval -> Ordering
Ord, forall x. Rep EpochInterval x -> EpochInterval
forall x. EpochInterval -> Rep EpochInterval x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep EpochInterval x -> EpochInterval
$cfrom :: forall x. EpochInterval -> Rep EpochInterval x
Generic)
deriving (Int -> EpochInterval -> ShowS
[EpochInterval] -> ShowS
EpochInterval -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EpochInterval] -> ShowS
$cshowList :: [EpochInterval] -> ShowS
show :: EpochInterval -> String
$cshow :: EpochInterval -> String
showsPrec :: Int -> EpochInterval -> ShowS
$cshowsPrec :: Int -> EpochInterval -> ShowS
Show) via Quiet EpochInterval
deriving newtype (Context -> EpochInterval -> IO (Maybe ThunkInfo)
Proxy EpochInterval -> String
forall a.
(Context -> a -> IO (Maybe ThunkInfo))
-> (Context -> a -> IO (Maybe ThunkInfo))
-> (Proxy a -> String)
-> NoThunks a
showTypeOf :: Proxy EpochInterval -> String
$cshowTypeOf :: Proxy EpochInterval -> String
wNoThunks :: Context -> EpochInterval -> IO (Maybe ThunkInfo)
$cwNoThunks :: Context -> EpochInterval -> IO (Maybe ThunkInfo)
noThunks :: Context -> EpochInterval -> IO (Maybe ThunkInfo)
$cnoThunks :: Context -> EpochInterval -> IO (Maybe ThunkInfo)
NoThunks, EpochInterval -> ()
forall a. (a -> ()) -> NFData a
rnf :: EpochInterval -> ()
$crnf :: EpochInterval -> ()
NFData, [EpochInterval] -> Encoding
[EpochInterval] -> Value
EpochInterval -> Bool
EpochInterval -> Encoding
EpochInterval -> Value
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> (a -> Bool)
-> ToJSON a
omitField :: EpochInterval -> Bool
$comitField :: EpochInterval -> Bool
toEncodingList :: [EpochInterval] -> Encoding
$ctoEncodingList :: [EpochInterval] -> Encoding
toJSONList :: [EpochInterval] -> Value
$ctoJSONList :: [EpochInterval] -> Value
toEncoding :: EpochInterval -> Encoding
$ctoEncoding :: EpochInterval -> Encoding
toJSON :: EpochInterval -> Value
$ctoJSON :: EpochInterval -> Value
ToJSON, Maybe EpochInterval
Value -> Parser [EpochInterval]
Value -> Parser EpochInterval
forall a.
(Value -> Parser a)
-> (Value -> Parser [a]) -> Maybe a -> FromJSON a
omittedField :: Maybe EpochInterval
$comittedField :: Maybe EpochInterval
parseJSONList :: Value -> Parser [EpochInterval]
$cparseJSONList :: Value -> Parser [EpochInterval]
parseJSON :: Value -> Parser EpochInterval
$cparseJSON :: Value -> Parser EpochInterval
FromJSON, Typeable EpochInterval
EpochInterval -> Encoding
(forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [EpochInterval] -> Size
(forall t. ToCBOR t => Proxy t -> Size)
-> Proxy EpochInterval -> 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 [EpochInterval] -> Size
$cencodedListSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy [EpochInterval] -> Size
encodedSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy EpochInterval -> Size
$cencodedSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size)
-> Proxy EpochInterval -> Size
toCBOR :: EpochInterval -> Encoding
$ctoCBOR :: EpochInterval -> Encoding
ToCBOR, Typeable EpochInterval
Proxy EpochInterval -> Text
forall s. Decoder s EpochInterval
forall a.
Typeable a
-> (forall s. Decoder s a) -> (Proxy a -> Text) -> FromCBOR a
label :: Proxy EpochInterval -> Text
$clabel :: Proxy EpochInterval -> Text
fromCBOR :: forall s. Decoder s EpochInterval
$cfromCBOR :: forall s. Decoder s EpochInterval
FromCBOR)
binOpEpochNo :: (Word64 -> Word64 -> Word64) -> EpochNo -> EpochNo -> EpochNo
binOpEpochNo :: (Word64 -> Word64 -> Word64) -> EpochNo -> EpochNo -> EpochNo
binOpEpochNo Word64 -> Word64 -> Word64
op EpochNo
en1 EpochNo
en2 = Word64 -> EpochNo
EpochNo forall a b. (a -> b) -> a -> b
$ Word64 -> Word64 -> Word64
op (EpochNo -> Word64
unEpochNo EpochNo
en1) (EpochNo -> Word64
unEpochNo EpochNo
en2)
addEpochInterval :: EpochNo -> EpochInterval -> EpochNo
addEpochInterval :: EpochNo -> EpochInterval -> EpochNo
addEpochInterval (EpochNo Word64
n) (EpochInterval Word32
m) = Word64 -> EpochNo
EpochNo (Word64
n forall a. Num a => a -> a -> a
+ forall a b. (Integral a, Num b) => a -> b
fromIntegral Word32
m)