module Blockfrost.Types.Shared.Slot
where
import Data.Aeson (FromJSON, ToJSON)
import GHC.Generics
import Servant.API (Capture, FromHttpApiData (..), ToHttpApiData (..))
import Servant.Docs (DocCapture (..), ToCapture (..), ToSample (..), samples)
newtype Slot = Slot Integer
deriving stock (Slot -> Slot -> Bool
(Slot -> Slot -> Bool) -> (Slot -> Slot -> Bool) -> Eq Slot
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Slot -> Slot -> Bool
== :: Slot -> Slot -> Bool
$c/= :: Slot -> Slot -> Bool
/= :: Slot -> Slot -> Bool
Eq, Eq Slot
Eq Slot =>
(Slot -> Slot -> Ordering)
-> (Slot -> Slot -> Bool)
-> (Slot -> Slot -> Bool)
-> (Slot -> Slot -> Bool)
-> (Slot -> Slot -> Bool)
-> (Slot -> Slot -> Slot)
-> (Slot -> Slot -> Slot)
-> Ord Slot
Slot -> Slot -> Bool
Slot -> Slot -> Ordering
Slot -> Slot -> Slot
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 :: Slot -> Slot -> Ordering
compare :: Slot -> Slot -> Ordering
$c< :: Slot -> Slot -> Bool
< :: Slot -> Slot -> Bool
$c<= :: Slot -> Slot -> Bool
<= :: Slot -> Slot -> Bool
$c> :: Slot -> Slot -> Bool
> :: Slot -> Slot -> Bool
$c>= :: Slot -> Slot -> Bool
>= :: Slot -> Slot -> Bool
$cmax :: Slot -> Slot -> Slot
max :: Slot -> Slot -> Slot
$cmin :: Slot -> Slot -> Slot
min :: Slot -> Slot -> Slot
Ord, Int -> Slot -> ShowS
[Slot] -> ShowS
Slot -> String
(Int -> Slot -> ShowS)
-> (Slot -> String) -> ([Slot] -> ShowS) -> Show Slot
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Slot -> ShowS
showsPrec :: Int -> Slot -> ShowS
$cshow :: Slot -> String
show :: Slot -> String
$cshowList :: [Slot] -> ShowS
showList :: [Slot] -> ShowS
Show, (forall x. Slot -> Rep Slot x)
-> (forall x. Rep Slot x -> Slot) -> Generic Slot
forall x. Rep Slot x -> Slot
forall x. Slot -> Rep Slot x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. Slot -> Rep Slot x
from :: forall x. Slot -> Rep Slot x
$cto :: forall x. Rep Slot x -> Slot
to :: forall x. Rep Slot x -> Slot
Generic)
deriving newtype (Integer -> Slot
Slot -> Slot
Slot -> Slot -> Slot
(Slot -> Slot -> Slot)
-> (Slot -> Slot -> Slot)
-> (Slot -> Slot -> Slot)
-> (Slot -> Slot)
-> (Slot -> Slot)
-> (Slot -> Slot)
-> (Integer -> Slot)
-> Num Slot
forall a.
(a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (Integer -> a)
-> Num a
$c+ :: Slot -> Slot -> Slot
+ :: Slot -> Slot -> Slot
$c- :: Slot -> Slot -> Slot
- :: Slot -> Slot -> Slot
$c* :: Slot -> Slot -> Slot
* :: Slot -> Slot -> Slot
$cnegate :: Slot -> Slot
negate :: Slot -> Slot
$cabs :: Slot -> Slot
abs :: Slot -> Slot
$csignum :: Slot -> Slot
signum :: Slot -> Slot
$cfromInteger :: Integer -> Slot
fromInteger :: Integer -> Slot
Num, Int -> Slot
Slot -> Int
Slot -> [Slot]
Slot -> Slot
Slot -> Slot -> [Slot]
Slot -> Slot -> Slot -> [Slot]
(Slot -> Slot)
-> (Slot -> Slot)
-> (Int -> Slot)
-> (Slot -> Int)
-> (Slot -> [Slot])
-> (Slot -> Slot -> [Slot])
-> (Slot -> Slot -> [Slot])
-> (Slot -> Slot -> Slot -> [Slot])
-> Enum Slot
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 :: Slot -> Slot
succ :: Slot -> Slot
$cpred :: Slot -> Slot
pred :: Slot -> Slot
$ctoEnum :: Int -> Slot
toEnum :: Int -> Slot
$cfromEnum :: Slot -> Int
fromEnum :: Slot -> Int
$cenumFrom :: Slot -> [Slot]
enumFrom :: Slot -> [Slot]
$cenumFromThen :: Slot -> Slot -> [Slot]
enumFromThen :: Slot -> Slot -> [Slot]
$cenumFromTo :: Slot -> Slot -> [Slot]
enumFromTo :: Slot -> Slot -> [Slot]
$cenumFromThenTo :: Slot -> Slot -> Slot -> [Slot]
enumFromThenTo :: Slot -> Slot -> Slot -> [Slot]
Enum, Num Slot
Ord Slot
(Num Slot, Ord Slot) => (Slot -> Rational) -> Real Slot
Slot -> Rational
forall a. (Num a, Ord a) => (a -> Rational) -> Real a
$ctoRational :: Slot -> Rational
toRational :: Slot -> Rational
Real, Enum Slot
Real Slot
(Real Slot, Enum Slot) =>
(Slot -> Slot -> Slot)
-> (Slot -> Slot -> Slot)
-> (Slot -> Slot -> Slot)
-> (Slot -> Slot -> Slot)
-> (Slot -> Slot -> (Slot, Slot))
-> (Slot -> Slot -> (Slot, Slot))
-> (Slot -> Integer)
-> Integral Slot
Slot -> Integer
Slot -> Slot -> (Slot, Slot)
Slot -> Slot -> Slot
forall a.
(Real a, Enum a) =>
(a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> (a, a))
-> (a -> a -> (a, a))
-> (a -> Integer)
-> Integral a
$cquot :: Slot -> Slot -> Slot
quot :: Slot -> Slot -> Slot
$crem :: Slot -> Slot -> Slot
rem :: Slot -> Slot -> Slot
$cdiv :: Slot -> Slot -> Slot
div :: Slot -> Slot -> Slot
$cmod :: Slot -> Slot -> Slot
mod :: Slot -> Slot -> Slot
$cquotRem :: Slot -> Slot -> (Slot, Slot)
quotRem :: Slot -> Slot -> (Slot, Slot)
$cdivMod :: Slot -> Slot -> (Slot, Slot)
divMod :: Slot -> Slot -> (Slot, Slot)
$ctoInteger :: Slot -> Integer
toInteger :: Slot -> Integer
Integral, Text -> Either Text Slot
ByteString -> Either Text Slot
(Text -> Either Text Slot)
-> (ByteString -> Either Text Slot)
-> (Text -> Either Text Slot)
-> FromHttpApiData Slot
forall a.
(Text -> Either Text a)
-> (ByteString -> Either Text a)
-> (Text -> Either Text a)
-> FromHttpApiData a
$cparseUrlPiece :: Text -> Either Text Slot
parseUrlPiece :: Text -> Either Text Slot
$cparseHeader :: ByteString -> Either Text Slot
parseHeader :: ByteString -> Either Text Slot
$cparseQueryParam :: Text -> Either Text Slot
parseQueryParam :: Text -> Either Text Slot
FromHttpApiData, Slot -> Text
Slot -> ByteString
Slot -> Builder
(Slot -> Text)
-> (Slot -> Builder)
-> (Slot -> ByteString)
-> (Slot -> Text)
-> (Slot -> Builder)
-> ToHttpApiData Slot
forall a.
(a -> Text)
-> (a -> Builder)
-> (a -> ByteString)
-> (a -> Text)
-> (a -> Builder)
-> ToHttpApiData a
$ctoUrlPiece :: Slot -> Text
toUrlPiece :: Slot -> Text
$ctoEncodedUrlPiece :: Slot -> Builder
toEncodedUrlPiece :: Slot -> Builder
$ctoHeader :: Slot -> ByteString
toHeader :: Slot -> ByteString
$ctoQueryParam :: Slot -> Text
toQueryParam :: Slot -> Text
$ctoEncodedQueryParam :: Slot -> Builder
toEncodedQueryParam :: Slot -> Builder
ToHttpApiData, Maybe Slot
Value -> Parser [Slot]
Value -> Parser Slot
(Value -> Parser Slot)
-> (Value -> Parser [Slot]) -> Maybe Slot -> FromJSON Slot
forall a.
(Value -> Parser a)
-> (Value -> Parser [a]) -> Maybe a -> FromJSON a
$cparseJSON :: Value -> Parser Slot
parseJSON :: Value -> Parser Slot
$cparseJSONList :: Value -> Parser [Slot]
parseJSONList :: Value -> Parser [Slot]
$comittedField :: Maybe Slot
omittedField :: Maybe Slot
FromJSON, [Slot] -> Value
[Slot] -> Encoding
Slot -> Bool
Slot -> Value
Slot -> Encoding
(Slot -> Value)
-> (Slot -> Encoding)
-> ([Slot] -> Value)
-> ([Slot] -> Encoding)
-> (Slot -> Bool)
-> ToJSON Slot
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> (a -> Bool)
-> ToJSON a
$ctoJSON :: Slot -> Value
toJSON :: Slot -> Value
$ctoEncoding :: Slot -> Encoding
toEncoding :: Slot -> Encoding
$ctoJSONList :: [Slot] -> Value
toJSONList :: [Slot] -> Value
$ctoEncodingList :: [Slot] -> Encoding
toEncodingList :: [Slot] -> Encoding
$comitField :: Slot -> Bool
omitField :: Slot -> Bool
ToJSON)
unSlot :: Slot -> Integer
unSlot :: Slot -> Integer
unSlot (Slot Integer
i) = Integer
i
instance ToCapture (Capture "slot_number" Slot) where
toCapture :: Proxy (Capture "slot_number" Slot) -> DocCapture
toCapture Proxy (Capture "slot_number" Slot)
_ = String -> String -> DocCapture
DocCapture String
"slot_number" String
"Slot position for requested block."
instance ToSample Slot where
toSamples :: Proxy Slot -> [(Text, Slot)]
toSamples = [(Text, Slot)] -> Proxy Slot -> [(Text, Slot)]
forall a. a -> Proxy Slot -> a
forall (f :: * -> *) a. Applicative f => a -> f a
pure ([(Text, Slot)] -> Proxy Slot -> [(Text, Slot)])
-> [(Text, Slot)] -> Proxy Slot -> [(Text, Slot)]
forall a b. (a -> b) -> a -> b
$ [Slot] -> [(Text, Slot)]
forall a. [a] -> [(Text, a)]
samples [Slot
37040682, Slot
412162133]