Just trying to wrap my head around Abilities and the Json
implementation at a deeper level, and I'm unsure about something.
What do we need the Encoding
ability in crates/compiler/builtins/roc/Encode.roc
for?
Encoding has
toEncoder : val -> Encoder fmt | val has Encoding, fmt has EncoderFormatting
I can delete Encoding
and all my Json tests still pass which seems strange.
Encoding should be going from a Roc type to a Json byte List.
Do you have tests for that?
Actually.. it is needed. I can't build roc
without it. Disregard my question above. @Brendan Hansknecht yeah I'm trying to add more tests, and fix bugs along the way.
I've got a strange bug I'm trying to track down. When I add the following test to the Json.roc
file it fails with Err (Leftover [123, ... all the other bytes])
. But when I add to another random file it passes.
It's strange because it doesn't even parse a single byte.
expect
input = Str.toUtf8 "{\"name\":\"Röc Lang\"}"
actual = Decode.fromBytes input fromUtf8
expected = Ok { name: "Röc Lang" }
actual == expected
Sure sounds like a compiler bug! Probably worth creating an issue. @Ayaz Hafiz is this something you know about?
seems like a bug in the JSON implementation, but not with abilities themselves. The JSON impl definitely could use some love
Last updated: Jul 05 2025 at 12:14 UTC