-
Notifications
You must be signed in to change notification settings - Fork 730
Refactor code using onLeft and onNothing #4815
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
Conversation
3195ef7
to
5a6fe9e
Compare
5a6fe9e
to
687701a
Compare
|
||
writeFilteredUTxOs sbe mOutFile result |
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.
Straight line code.
-- so our ondisk op cert counter must be greater than or | ||
-- equal to what is in the node state | ||
Just ptclStateCounter -> return (OpCertOnDiskCounter onDiskOpCertCount, Just $ OpCertNodeStateCounter ptclStateCounter) | ||
Nothing -> return (OpCertOnDiskCounter onDiskOpCertCount, Nothing) |
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.
Straight line code.
|
||
let qInMode = QueryInEra eInMode . QueryInShelleyBasedEra sbe $ QueryDebugLedgerState | ||
|
||
result <- executeQuery era cModeParams localNodeConnInfo qInMode |
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.
Straight line code.
Nothing -> left $ ShelleyQueryCmdEraConsensusModeMismatch (AnyConsensusMode cMode) anyE | ||
case cMode of | ||
CardanoMode -> eligibleWriteProtocolStateConstaints sbe $ writeProtocolState mOutFile result | ||
mode -> left . ShelleyQueryCmdUnsupportedMode $ AnyConsensusMode mode |
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.
Straight line code.
|
||
result <- executeQuery era cModeParams localNodeConnInfo query | ||
|
||
writeStakeAddressInfo mOutFile $ DelegationsAndRewards result |
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.
Straight line code.
) | ||
) | ||
|
||
liftIO . LBS.putStrLn $ encodePretty poolStates |
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.
Straight line code.
|
||
let query = QueryInEra eInMode . QueryInShelleyBasedEra sbe $ QueryStakeDistribution | ||
|
||
result <- executeQuery era cModeParams localNodeConnInfo query |
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.
Straight line code.
687701a
to
d47a3e3
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.
Nice work 👍 . Just replace throwE
with left
and I'll approve. You can squash all the commits if you like since its just a refactoring and not difficult to understand what is going on.
bench/locli/app/locli.hs
Outdated
@@ -1,12 +1,10 @@ | |||
{-# LANGUAGE OverloadedStrings #-} |
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.
👍
All occurrences of |
58e4736
to
1af4803
Compare
1af4803
to
6d731c4
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.
LGTM!
6d731c4
to
f0571e9
Compare
bors r+ |
4815: Refactor code using onLeft and onNothing r=newhoggy a=newhoggy Using `onLeft` and `onNothing` gives more opportunities for straight line code. Examples of this are marked. Modifying the code elsewhere as well for general consistency. This PR is divided into multiple commits to group related changes for easy review. Note, `throwE` from `Control.Monad.Trans.Except` is the same as `left` from `Control.Monad.Trans.Except.Extra`. Co-authored-by: John Ky <[email protected]>
Timed out. |
bors merge |
Build succeeded: |
Using
onLeft
andonNothing
gives more opportunities for straight line code. Examples of this are marked.Modifying the code elsewhere as well for general consistency.
This PR is divided into multiple commits to group related changes for easy review.
Note,
throwE
fromControl.Monad.Trans.Except
is the same asleft
fromControl.Monad.Trans.Except.Extra
.