dhall-lang / dhall-haskell

Maintainable configuration files
https://dhall-lang.org/
BSD 3-Clause "New" or "Revised" License
912 stars 213 forks source link

FromDhall instances for Char8 ByteStrings? #2488

Open Odeyaloleg opened 1 year ago

Odeyaloleg commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

We probably wouldn't be able to add a dedicated constructor unless https://github.com/dhall-lang/dhall-lang/issues/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)