Skip to content
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

FromDhall instances for Char8 ByteStrings? #2488

Open
Odeyaloleg opened this issue Feb 2, 2023 · 3 comments
Open

FromDhall instances for Char8 ByteStrings? #2488

Odeyaloleg opened this issue Feb 2, 2023 · 3 comments
Labels
marshalling Marshalling between Dhall and Haskell

Comments

@Odeyaloleg
Copy link

From what I see we didn't get an instance for any of ByteString types. Is there a reason for that? Would be good to know the details.
I would like to have instances for Char8 ByteStrings to avoid redundant conversions to other String-like types after reading from config.
Thanks!

@sjakobi sjakobi added the marshalling Marshalling between Dhall and Haskell label Feb 2, 2023
@sjakobi
Copy link
Collaborator

sjakobi commented Feb 2, 2023

Note that bytestring doesn't provide separate types from its Char8 modules – therefore any instance must assume that a ByteString is just a binary blob. However there could be dedicated Decoders and Encoders for converting between Latin-1-encoded ByteStrings and the Dhall Text type.

@Odeyaloleg
Copy link
Author

I am trying to write Data.ByteString.ByteString Decoder and wondering if I should add another constructors family for Expr data type or try to make Chunks type polymorphic over string-like type and use it in decoder. Or I am thinking in a wrong direction?

Decoders and Encoders for converting between Latin-1-encoded ByteStrings and the Dhall Text type

Just wondering, why Latin-1? @sjakobi

@Gabriella439
Copy link
Collaborator

We probably wouldn't be able to add a dedicated constructor unless dhall-lang/dhall-lang#1179 were standardized

Instead, what you probably want to do is to have the Encoder/Decoder use the TextLit constructor along with some textual encoding of the bytes (e.g. base64 encoding or something similar)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
marshalling Marshalling between Dhall and Haskell
Projects
None yet
Development

No branches or pull requests

3 participants