Closed carlhammann closed 1 year ago
Perhaps you can deprecate the function, to go one step further?
As it stands, the implementation of MonadModal
for the staged monad relies on runTweakInChain
, and the reason why is quite interesting: If we were to abandon runTweakInChain :: MonadPlus m => ... -> m (a, TxSkel)
in favour of runTweakInChain' :: ... -> m [(a, TxSkel)]
, that would mean that we'd have to replace everything starting at this line by something like
modifedSkels <- runTweakInChain' now skel
msum $
map (\(_, skel') -> do
lift $
lift $
tell
[ MCLogSubmittedTxSkel
(SkelContext managedTxOuts managedDatums)
skel'
]
tx <- validateTxSkel skel'
lift $
lift $
tell
[MCLogNewTx (Ledger.getCardanoTxId tx)]
put later
return tx
)
modifiedSkels
The difference is that, in the version we currently have, if one result of the tweak fails with a fail
or throwError
, the other results will still be tried. In the other version, if one alternative fails, no modified transaction is tried.
This clarifies the documentation comment for
runTweakInChain
and adds a functionwhich allows one to manually apply a tweak to a transaction, returning all modified transactions in a list.
@gabrielhdt and I discussed something like this in the morning, and because I'm not convinced that this feature is useful in the spirit of much of the rest of cooked, at least
MonadModalBlockChain
, I thought I'd open this PR to discuss it with you.