roc-lang / roc

A fast, friendly, functional language.
https://roc-lang.org
Universal Permissive License v1.0
3.86k stars 284 forks source link

Move Json out of the standard library #5373

Open ayazhafiz opened 1 year ago

ayazhafiz commented 1 year ago

Today we have a Json module in the builtins that should not exist there longer-term. We'd like to move the JSON module to user space.

Removing Json is not as simple as deleting the file because many compiler-internal tests rely on the existence of the module for testing abilities.

So, the first step of this issue will be creating a synthetic encoder/decoder implementation that those tests can use inside of the compiler itself (this can just be a raw string that implement a Roc encoder/decoder faithfully), and updating all tests that depend on Json to use that module instead.

lukewilliamboswell commented 1 year ago

To clarify @ayazhafiz, do we need an opaque type that lives in crates/compiler/builtins/roc, it fully implements the Encode and Decode abilities, and replaces Json in the relevant tests in crates/compiler/test_gen/src/gen_abilities.rs and crates/compiler/test_mono/src/tests.rs?

Should this type be a builtin or can it live somewhere else? I assume we don't want it to show up in docs generation or accidentally shadow another module.

ayazhafiz commented 1 year ago

As discussed in private communication, this module need not be in the builtins. A string representation used in the tests will do. m

shua commented 3 days ago

Can I take this ticket? I've got a PR ready #6845