-
Notifications
You must be signed in to change notification settings - Fork 722
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
Extend deserialiseFromRawBytesHex to produce error description #3304
Conversation
3d6754f
to
49395c0
Compare
49395c0
to
bbf878a
Compare
bbf878a
to
c6b9946
Compare
c6b9946
to
2f8a9a7
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.
Right, let's reorganize these commits:
Commit 1: Change to deserialiseFromRawBytesHex
Commit 2: Propagating this change throughout the repo
Commit 3: Miscellaneous refactorings
2f8a9a7
to
0c449a8
Compare
done |
0c449a8
to
602084e
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.
Right direction, a few comments
case Base16.decode hex of | ||
Right raw -> deserialiseFromRawBytes proxy raw | ||
Left _msg -> Nothing | ||
=> AsType a -> ByteString -> Either String a |
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.
String
isn't a particularly indicative error type. We should create a custom datatype, for example:
data RawBytesHexError = RawBytesHexErrorBase16DecodeFail ByteString String | RawBytesHexErrorRawBytesDecodeFail ByteString String
We can also implement an Error
instance to render the errors.
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 think it should be done in another patch. String is used already everywhere.
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.
String is used already everywhere.
And it shouldn't be. Even more reason to change the error type.
5d6bc07
to
039952d
Compare
994a333
to
6e9ecac
Compare
3911a12
to
8ce6b0f
Compare
8ce6b0f
to
5dacedb
Compare
bors merge |
Build failed: |
64dd0ec
to
7c4093e
Compare
2337440
to
f8835a0
Compare
94c2835
to
87645b3
Compare
bors merge |
This PR was included in a batch that successfully built, but then failed to merge into master. It will not be retried. Additional information: {"message":"Waiting on code owner review from MarcFontaine, cleverca22, deepfire, denisshevchenko, and/or jutaro.","documentation_url":"https://docs.github.com/articles/about-protected-branches"} |
bors merge |
This PR was included in a batch that successfully built, but then failed to merge into master. It will not be retried. Additional information: {"message":"Waiting on code owner review from MarcFontaine, cleverca22, deepfire, denisshevchenko, and/or jutaro.","documentation_url":"https://docs.github.com/articles/about-protected-branches"} |
data RawBytesHexError | ||
= RawBytesHexErrorBase16DecodeFail | ||
ByteString -- ^ original input | ||
String -- ^ error message |
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 not do better than a String 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.
Sorry? Too much indirection for my English.
Do you suggest having something more structured than a String in the second field of RawBytesHexErrorBase16DecodeFail or not?
case deserialiseFromRawBytesHex AsTxId (BSC.pack str) of | ||
Just addr -> return addr | ||
Nothing -> fail $ "Incorrect transaction id format:: " ++ show str | ||
str <- some Parsec.hexDigit <?> "transaction id (hexadecimal)" |
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.
Was there a reason to switch many1
to some
? The Parsec version has an implementation specialised to parsers.
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.
some
is a less surprising name for the same thing.
@@ -1974,7 +1975,7 @@ parseTxIn = TxIn <$> parseTxId <*> (Parsec.char '#' *> parseTxIx) | |||
|
|||
parseTxId :: Parsec.Parser TxId | |||
parseTxId = do | |||
str <- Parsec.many1 Parsec.hexDigit Parsec.<?> "transaction id (hexadecimal)" | |||
str <- some Parsec.hexDigit <?> "transaction id (hexadecimal)" |
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.
Same question. Is this change needed? Why?
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 concerning the tx-generator
87645b3
to
beae391
Compare
bors merge |
Build succeeded: |
No description provided.