Implemented TH splices for validated ByteString literals#712
Implemented TH splices for validated ByteString literals#712Bodigrim merged 1 commit intohaskell:masterfrom
Conversation
70f1a6a to
b53c921
Compare
|
@Bodigrim I don't understand what's going on with CI. Any help appreciated. |
|
@vdukhovni no idea tbh. Maybe something changed under the hood, either in runner images or in the haskell action. |
|
I have very little experience tuning GitHub CI. Any chance someone can help? |
|
It seems it was an intermittent failure with https://github.com/haskell-actions/setup. I don't think you need to touch CI setup in this PR. |
|
Thanks, indeed most of the problems appear to have been transient. I reverted the CI changes, and the only failure so far is with Otherwise, no issues. So I think I'm done, unless you'd prefer to name the two functions differently. The names |
hsyl20
left a comment
There was a problem hiding this comment.
LGTM
I would prefer more explicit names: something like literalFromAscii (or literalFromChar8) and literalFromHex
Many thanks for the prompt review! I'm about to push a fixup for all the nits, and what remains then is to reach consensus on the splice names. Of the above I prefer |
Yes the type and |
c5906d9 to
28a0cb6
Compare
83cf073 to
2f5671a
Compare
| import Data.Bits ((.&.)) | ||
| import Data.Bits ((.|.), (.&.), complement, shiftL) | ||
| import Data.Char (ord) | ||
| import Data.Foldable (foldr') |
There was a problem hiding this comment.
The unqualified foldr' briefly confused me. (Actually, why are these quote-generators defined in D.B.Internal.Type instead of the exposed Data.ByteString?)
| literalFromChar8 "" = [||empty||] | ||
| literalFromChar8 s = case foldr' op (Octets 0 []) s of | ||
| Octets n ws -> liftTyped (unsafePackLenBytes n ws) | ||
| Hichar i w -> liftCode $ fail $ "non-octet character '\\" ++ |
There was a problem hiding this comment.
@TeofilC Would this liftCode $ fail $ ... stuff require any adjustments to your template-haskell-lift plans?
There was a problem hiding this comment.
Thanks for the headsup. This should be fine.
8b3189d to
d8c2d02
Compare
|
Anything still to do on my end? |
clyring
left a comment
There was a problem hiding this comment.
LGTM, but:
- I would want to pluralize the name
literalFromChar8(which looks singular). Perhaps justliteralFromChar8sorliteralFromString8. But there probably isn't much room for confusion anyway. - I suspect you will want to make a clean commit message.
I ultimately don't have strong views about the naming, so willing to make changes, but my intuition is that
Sure, I'll squash and update the commit message. |
The |
literalFromOctetString :: Quote m => String -> Code m ByteString
literalFromHex :: Quote m => String -> Code m ByteString
The former rejects inputs with non-octet code points above 0xFF.
The latter rejects odd-length inputs or inputs with characters
other than non-hexadecimal digits.
|
Sadly, not enough info about why the OpenBSD CI run failed, looks unrelated to this PR, as various other |
|
Thanks a ton and sorry for the wait! (OpenBSD failure is probably because not enough free space on the default partition, unrelated to this branch) |
The former rejects inputs with non-octet code points above 0xFF. The latter rejects odd-length inputs or inputs with characters other than non-hexadecimal digits.