Just had a go at converting handling our SyncEnv via an MTL.
Been having trouble when trying to log something whilst debugging and it always involves passing along SyncEnv through all the functions. Also it can be quite a pain to pass SyncEnv + Trace IO Text all the time:
It's quite nice to use, here's an example:
fnc :: App (Bool)
fnc = do
syncEnv <- ask
epochState <- asks envEpochState
pure True
Got a bunch of helper functions that can be used when in the App monad:
-- | Get `Trace` from the `SyncEnv`.
askTrace :: App (Trace IO Text)
-- | Get `Ledger.Network` from the `SyncEnv`.
askNetwork :: App Ledger.Network
-- | Get `InsertOptions` from the `SyncEnv`.
askInsertOptions :: App InsertOptions
There's one error I can't work out how it happened but in /Config/Cardano.hs saying that there is an instance missing when trying to use protocolInfoCardano:
mkProtocolInfoCardano ::
GenesisConfig ->
[Consensus.ShelleyLeaderCredentials StandardCrypto] -> -- this is not empty only in tests
(ProtocolInfo CardanoBlock, IO [BlockForging IO CardanoBlock])
mkProtocolInfoCardano genesisConfig shelleyCred =
protocolInfoCardano
CardanoProtocolParams
{ paramsByron =
error:
No instance for (Ouroboros.Consensus.Ledger.SupportsProtocol.LedgerSupportsProtocol
(Ouroboros.Consensus.Shelley.Ledger.Block.ShelleyBlock
(Ouroboros.Consensus.Protocol.TPraos.TPraos StandardCrypto)
(cardano-ledger-shelley-1.11.0.0:Cardano.Ledger.Shelley.Era.ShelleyEra
StandardCrypto)))
arising from a use of ‘protocolInfoCardano’
...
Description
Just had a go at converting handling our
SyncEnv
via an MTL. Been having trouble when trying to log something whilst debugging and it always involves passing alongSyncEnv
through all the functions. Also it can be quite a pain to passSyncEnv
+Trace IO Text
all the time:It's quite nice to use, here's an example:
Got a bunch of helper functions that can be used when in the
App
monad:There's one error I can't work out how it happened but in
/Config/Cardano.hs
saying that there is an instance missing when trying to useprotocolInfoCardano
:error: