Dhall for Word8, Word16, Double, etc

Hi, Let's say I have a record type: data Foo = Foo { v :: Word16 } I want to have a FromDhall instance for Foo. I know this is easy to do if v is Integer instead of Word16. But v is Word16. Does Dhall enable the user to cleanly express how to input a Word16 with the requisite range checks, or is the user expected to only use Integer and do his own conversion and range checks within Haskell after inputting the Integer from Dhall? I have a record with Word32, Word16, Word8 & Double fields instead of Integer & Scientific.

Correction to my original message: No problems for Double, which already
has a FromDhall instance, but I'm trying to solve the problem for Word8,
Word16 & Word32.
Interestingly, Word8, Word16 & Word32 have ToDhall instances but no
FromDhall instances.
On Wed, Aug 19, 2020 at 2:50 PM ☂Josh Chia (謝任中)
Hi,
Let's say I have a record type: data Foo = Foo { v :: Word16 }
I want to have a FromDhall instance for Foo. I know this is easy to do if v is Integer instead of Word16. But v is Word16. Does Dhall enable the user to cleanly express how to input a Word16 with the requisite range checks, or is the user expected to only use Integer and do his own conversion and range checks within Haskell after inputting the Integer from Dhall? I have a record with Word32, Word16, Word8 & Double fields instead of Integer & Scientific.

I guess if one had FromDhall instances you would need to fail sometimes! What I have done in such situations is make separate TypeDhallVersion types which I convert by hand. Cheers, Vanessa McHale
On Aug 19, 2020, at 1:55 AM, ☂Josh Chia (謝任中)
wrote: Correction to my original message: No problems for Double, which already has a FromDhall instance, but I'm trying to solve the problem for Word8, Word16 & Word32.
Interestingly, Word8, Word16 & Word32 have ToDhall instances but no FromDhall instances.
On Wed, Aug 19, 2020 at 2:50 PM ☂Josh Chia (謝任中)
mailto:joshchia@gmail.com> wrote: Hi, Let's say I have a record type: data Foo = Foo { v :: Word16 }
I want to have a FromDhall instance for Foo. I know this is easy to do if v is Integer instead of Word16. But v is Word16. Does Dhall enable the user to cleanly express how to input a Word16 with the requisite range checks, or is the user expected to only use Integer and do his own conversion and range checks within Haskell after inputting the Integer from Dhall? I have a record with Word32, Word16, Word8 & Double fields instead of Integer & Scientific.
_______________________________________________ Haskell-Cafe mailing list To (un)subscribe, modify options or view archives go to: http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe Only members subscribed via the mailman list are allowed to post.

Hi Josh!
dhall already provides FromDhall instances for Set and HashSet, which
fail when the input Dhall list contains duplicates. Adding instances
for e.g. Word8 that would fail when the source Natural is greater than
255 doesn't seem like a stretch.
Please do open an issue at
https://github.com/dhall-lang/dhall-haskell/issues so we can discuss
the idea with the other maintainers.
Cheers,
Simon
Am Mi., 19. Aug. 2020 um 08:56 Uhr schrieb ☂Josh Chia (謝任中)
Correction to my original message: No problems for Double, which already has a FromDhall instance, but I'm trying to solve the problem for Word8, Word16 & Word32.
Interestingly, Word8, Word16 & Word32 have ToDhall instances but no FromDhall instances.
On Wed, Aug 19, 2020 at 2:50 PM ☂Josh Chia (謝任中)
wrote: Hi,
Let's say I have a record type: data Foo = Foo { v :: Word16 }
I want to have a FromDhall instance for Foo. I know this is easy to do if v is Integer instead of Word16. But v is Word16. Does Dhall enable the user to cleanly express how to input a Word16 with the requisite range checks, or is the user expected to only use Integer and do his own conversion and range checks within Haskell after inputting the Integer from Dhall? I have a record with Word32, Word16, Word8 & Double fields instead of Integer & Scientific.
_______________________________________________ Haskell-Cafe mailing list To (un)subscribe, modify options or view archives go to: http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe Only members subscribed via the mailman list are allowed to post.
participants (3)
-
Simon Jakobi
-
Vanessa McHale
-
☂Josh Chia (謝任中)