-
Notifications
You must be signed in to change notification settings - Fork 41
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
Clear out psbFromBytes, quasiquoter #294
Conversation
cardano-crypto-class/src/Cardano/Crypto/PinnedSizedBytes/Internal.hs
Outdated
Show resolved
Hide resolved
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 good to me, apart from the one remark on the previous review.
@tdammers - your comment has already been addressed a few commits ago. I can't reply to it, as it's marked 'outdated'. |
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 particularly like the reimplementation of hex conversion. For performance, maintainability and correctness reasons. How can we change that?
decodeAndCount chunk | ||
| Text.length chunk /= 2 = do | ||
len <- get | ||
fail $ "Odd number of hexits (" <> show (2 * len + 1) <> ")." | ||
| otherwise = case readMaybe ("0x" <> Text.unpack chunk) of | ||
Nothing -> fail $ "Invalid hexit pair (" <> Text.unpack chunk <> ")." | ||
Just w8 -> modify (+ 1) $> w8 |
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.
Why are you reimplementing from hex conversion? Why not just use base16-bytestring?
This attempts to resolve #291. In particular:
psbFromBytes
are gone.IsString PinnedSizedBytes
is gone.psbHex
has been added for compile-time construction.Some refactors to enable the quasiquoter have also been added.
Currently, I'm submitting this as a draft, as I can't (quite) figure out how to stop the quasiquoter making two identical hex strings constructPinnedSizedBytes
which share the same address. This is reproduced by one of the tests, which is currently failing. I attempted to address this by porting overprimitive
'sLift
instance forByteArray
, but that doesn't seem to help any.Upon further attempts, I'm basically giving up on this, and leaving a note about not mutating the outcomes of the quasiquoter. This is basically for two reasons:
@lehins - tagging you for a review.