| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Ouroboros.Consensus.HardFork.History.Qry
Contents
Synopsis
- data Qry :: Type -> Type
- data Expr (f :: Type -> Type) :: Type -> Type where
- EVar :: f a -> Expr f a
- ELit :: Show a => a -> Expr f a
- ELet :: Expr f a -> (f a -> Expr f b) -> Expr f b
- EPair :: Expr f a -> Expr f b -> Expr f (a, b)
- EFst :: Expr f (a, b) -> Expr f a
- ESnd :: Expr f (a, b) -> Expr f b
- EAbsToRelTime :: Expr f RelativeTime -> Expr f TimeInEra
- EAbsToRelSlot :: Expr f SlotNo -> Expr f SlotInEra
- EAbsToRelEpoch :: Expr f EpochNo -> Expr f EpochInEra
- ERelToAbsTime :: Expr f TimeInEra -> Expr f RelativeTime
- ERelToAbsSlot :: Expr f (SlotInEra, TimeInSlot) -> Expr f SlotNo
- ERelToAbsEpoch :: Expr f (EpochInEra, SlotInEpoch) -> Expr f EpochNo
- ERelTimeToSlot :: Expr f TimeInEra -> Expr f (SlotInEra, TimeInSlot)
- ERelSlotToTime :: Expr f SlotInEra -> Expr f TimeInEra
- ERelSlotToEpoch :: Expr f SlotInEra -> Expr f (EpochInEra, SlotInEpoch)
- ERelEpochToSlot :: Expr f EpochInEra -> Expr f SlotInEra
- ESlotLength :: Expr f SlotNo -> Expr f SlotLength
- EEpochSize :: Expr f EpochNo -> Expr f EpochSize
- data PastHorizonException = PastHorizon {
- pastHorizonCallStack :: CallStack
- pastHorizonExpression :: Some ClosedExpr
- pastHorizonSummary :: [EraSummary]
- qryFromExpr :: (forall f. Expr f a) -> Qry a
- runQuery :: forall a xs. HasCallStack => Qry a -> Summary xs -> Either PastHorizonException a
- runQueryThrow :: (HasCallStack, MonadThrow m) => Qry a -> Summary xs -> m a
- runQueryPure :: HasCallStack => Qry a -> Summary xs -> a
- data Interpreter xs
- mkInterpreter :: Summary xs -> Interpreter xs
- interpretQuery :: HasCallStack => Interpreter xs -> Qry a -> Either PastHorizonException a
- wallclockToSlot :: RelativeTime -> Qry (SlotNo, NominalDiffTime, NominalDiffTime)
- slotToWallclock :: SlotNo -> Qry (RelativeTime, SlotLength)
- slotToEpoch' :: SlotNo -> Qry (EpochNo, Word64)
- slotToEpoch :: SlotNo -> Qry (EpochNo, Word64, Word64)
- epochToSlot' :: EpochNo -> Qry SlotNo
- epochToSlot :: EpochNo -> Qry (SlotNo, EpochSize)
- epochToSize :: EpochNo -> Qry EpochSize
Documentation
data Qry :: Type -> Type Source #
Query
Qry adds a monadic interface on top of Expr. Although means that Qry
itself is not showable, the PastHorizonException can nonetheless show the
offending expression alongside the Summary against which it was evaluated.
data Expr (f :: Type -> Type) :: Type -> Type where Source #
Query expressions in PHOAS
Constructors
| EVar :: f a -> Expr f a | |
| ELit :: Show a => a -> Expr f a | |
| ELet :: Expr f a -> (f a -> Expr f b) -> Expr f b | |
| EPair :: Expr f a -> Expr f b -> Expr f (a, b) | |
| EFst :: Expr f (a, b) -> Expr f a | |
| ESnd :: Expr f (a, b) -> Expr f b | |
| EAbsToRelTime :: Expr f RelativeTime -> Expr f TimeInEra | |
| EAbsToRelSlot :: Expr f SlotNo -> Expr f SlotInEra | |
| EAbsToRelEpoch :: Expr f EpochNo -> Expr f EpochInEra | |
| ERelToAbsTime :: Expr f TimeInEra -> Expr f RelativeTime | |
| ERelToAbsSlot :: Expr f (SlotInEra, TimeInSlot) -> Expr f SlotNo | |
| ERelToAbsEpoch :: Expr f (EpochInEra, SlotInEpoch) -> Expr f EpochNo | |
| ERelTimeToSlot :: Expr f TimeInEra -> Expr f (SlotInEra, TimeInSlot) | |
| ERelSlotToTime :: Expr f SlotInEra -> Expr f TimeInEra | |
| ERelSlotToEpoch :: Expr f SlotInEra -> Expr f (EpochInEra, SlotInEpoch) | |
| ERelEpochToSlot :: Expr f EpochInEra -> Expr f SlotInEra | |
| ESlotLength :: Expr f SlotNo -> Expr f SlotLength | |
| EEpochSize :: Expr f EpochNo -> Expr f EpochSize |
data PastHorizonException Source #
We tried to convert something that is past the horizon
That is, we tried to convert something that is past the point in time beyond which we lack information due to uncertainty about the next hard fork.
Constructors
| PastHorizon | |
Fields
| |
Instances
| Show PastHorizonException Source # | |
Defined in Ouroboros.Consensus.HardFork.History.Qry Methods showsPrec :: Int -> PastHorizonException -> ShowS # show :: PastHorizonException -> String # showList :: [PastHorizonException] -> ShowS # | |
| Exception PastHorizonException Source # | |
Defined in Ouroboros.Consensus.HardFork.History.Qry Methods toException :: PastHorizonException -> SomeException # fromException :: SomeException -> Maybe PastHorizonException # | |
runQuery :: forall a xs. HasCallStack => Qry a -> Summary xs -> Either PastHorizonException a Source #
Run a query
Unlike an Expr, which is evaluated in a single era, a Qry is evaluated
against all eras. Only if all Exprs embedded in the Qry can be
evaluated in the same era (we don't want to mix properties of different
eras in one query) do we return the result. If there is no era in which we
can evaluate all Exprs in the Qry, we report a PastHorizonException.
NOTE: this means that queries about separate eras have to be run separately, they should not be composed into a single query. How could we know to which era which relative slot/time refers?
runQueryThrow :: (HasCallStack, MonadThrow m) => Qry a -> Summary xs -> m a Source #
runQueryPure :: HasCallStack => Qry a -> Summary xs -> a Source #
Interpreter
data Interpreter xs Source #
Can be sent across the LocalStateQuery protocol to interpret queries in the wallet.
The Summary should be considered internal.
Instances
| Eq (Interpreter xs) Source # | |
Defined in Ouroboros.Consensus.HardFork.History.Qry Methods (==) :: Interpreter xs -> Interpreter xs -> Bool # (/=) :: Interpreter xs -> Interpreter xs -> Bool # | |
| Show (Interpreter xs) Source # | |
Defined in Ouroboros.Consensus.HardFork.History.Qry Methods showsPrec :: Int -> Interpreter xs -> ShowS # show :: Interpreter xs -> String # showList :: [Interpreter xs] -> ShowS # | |
| SListI xs => Serialise (Interpreter xs) Source # | |
Defined in Ouroboros.Consensus.HardFork.History.Qry Methods encode :: Interpreter xs -> Encoding Source # decode :: Decoder s (Interpreter xs) Source # encodeList :: [Interpreter xs] -> Encoding Source # decodeList :: Decoder s [Interpreter xs] Source # | |
mkInterpreter :: Summary xs -> Interpreter xs Source #
interpretQuery :: HasCallStack => Interpreter xs -> Qry a -> Either PastHorizonException a Source #
Specific queries
wallclockToSlot :: RelativeTime -> Qry (SlotNo, NominalDiffTime, NominalDiffTime) Source #
Translate UTCTime to SlotNo
Additionally returns the time spent and time left in this slot.
slotToWallclock :: SlotNo -> Qry (RelativeTime, SlotLength) Source #
Translate SlotNo to the UTCTime at the start of that slot
Additionally returns the length of the slot.