-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Integrate RIO monad part 1 #1033
Conversation
69744e1
to
989ba8a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we finish ADR first?
510a872
to
796aaf1
Compare
796aaf1
to
5a36d5d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tactical merge block - I need to play with it
|
||
fromEitherIOCli :: (HasCallStack, MonadIO m, Show e, Typeable e, Error e) => IO (Either e a) -> m a | ||
fromEitherIOCli action = do | ||
result <- liftIO action |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is more complicated than just liftIO
. We need to catch all synchronous exceptions here and wrap them, and also provide the call stack. So basically we need analogous wrapper to CustomCliException
but for Exception
s this time.
This is because IOException
for example does not carry the call stack with it (yet), so we should manually add it to it.
Unfortunately it'll be just a call stack up to fromEitherIOCli
call.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are not catching exceptions. We are converting errors to exceptions via CustomCliException
. Perhaps we should change the name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, you are right. I'm talking about a slightly different situation: that IO exceptions from this line sometimes won't have call stack. We can do something about it here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could make this even more robust by making CIO a newtype, and not providing MonadIO
: 3c1f6f0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you update the ADR with this first?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks promising. We're getting there. Can you address my comments?
5a36d5d
to
3b56ca8
Compare
shelleyBasedEraConstraints sbe $ do | ||
sks <- mapM (fromEitherIOCli . readWitnessSigningData) witnesses | ||
|
||
allOuts <- fromEitherIOCli . runExceptT $ mapM (toTxOutInAnyEra sbe) outs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
adding another function
fromExceptTCli = fromEitherIOCli . runExceptT
could save us some boilerplate
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm hesitant about this because we want to remove ExceptT
usage.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But what about cardano-api? We agreed to not throw exceptions there
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand what you mean. We want to remove ExceptT
usage in cardano-cli
. I.e not implement functions in ExceptT
. We can introduce a function like you suggested but it needs to be clear that it's only for use if we are importing functions from a package that does use ExceptT
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have functions returning a type ExceptT e m a
in cardano-api. We still need to use them in cardano-cli.
3b56ca8
to
8e380af
Compare
8e380af
to
c279d97
Compare
Changelog
Context
How to trust this PR
Highlight important bits of the PR that will make the review faster. If there are commands the reviewer can run to observe the new behavior, describe them.
Checklist