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

Concept: JSON Decoders #538

Open
jiegillet opened this issue Nov 27, 2022 · 6 comments · May be fixed by #694
Open

Concept: JSON Decoders #538

jiegillet opened this issue Nov 27, 2022 · 6 comments · May be fixed by #694
Assignees
Labels
x:action/create Work on something from scratch x:knowledge/intermediate Quite a bit of Exercism knowledge required x:module/concept Work on Concepts x:module/concept-exercise Work on Concept Exercises x:priority/high Has a higher priority than other issues x:size/large Large amount of work x:type/content Work on content (e.g. exercises, concepts)

Comments

@jiegillet
Copy link
Contributor

Design

Goal

The Goal is to learn to use the Json.Decode and Json.Encode modules.

Learning objectives

Students should be able to

  • encode any JSON Value (Json.Encode.object, list and other primitives)
  • prettify a value (encode)
  • understand why decoders are useful even though the concept is unusual
  • decode JSON primitives (bool, int, string...)
  • decode data structures (list, dict, nullable)
  • decode objects (field, at)
  • deal with uncertainty (maybe, oneOf)
  • modify and chain decoders (map, andThen, succeed)
  • test a decoder on a string input (decodeString)

Out of scope

  • encoder aliases (array, set)
  • more niche decoders (array, keyValuePairs, oneOrMore, index, null, value)
  • dealing with Error and fail
  • decoding recursive structures (lazy, a quick mention is fine)

Concepts

The concept this exercise unlocks is:

  • json

Prerequisites

  • strings
  • lists
  • dict
  • records
  • maybe
  • custom-types (?)

Analyzer

TBD depending on the exercise


Comments

@jiegillet jiegillet added x:action/create Work on something from scratch x:knowledge/intermediate Quite a bit of Exercism knowledge required x:module/concept Work on Concepts x:module/concept-exercise Work on Concept Exercises x:type/content Work on content (e.g. exercises, concepts) x:size/large Large amount of work x:priority/high Has a higher priority than other issues labels Nov 27, 2022
@jiegillet jiegillet self-assigned this Oct 23, 2023
@jiegillet
Copy link
Contributor Author

@ceddlyburge related to our discussion on #621, I went through the exercises that we don't have implemented yet (bin/configlet info) to look for other exercises that we could use to practice JSON decoding, but hopefully a bit simpler than rest-api.

Basically no other is meant to practice JSON, so we would have to stretch some scopes.

I found two that may be interesting: pov and zipper. Those two exercises involve trees, pov is bout rerooting trees and zipper traversing trees. I say that they are interesting because parsing trees is fun, all the other exercises have very standard, predictable inputs.
Unfortunately, these 2 are not really easy, so it doesn't help us that much.

If we are OK with very simple decoding, maybe we could use affine-cipher.

Best for last: bank-account could work as well, transforming the string instructions into meaningful types.

What do you think?

@ceddlyburge
Copy link
Contributor

I think the api concept is still good, its just that it is complicated, and the instructions are not as clear as they might be (especially for Elm I think).

Maybe we could jump on a call sometime and discuss how to make it clear what the student is supposed to do?

@jiegillet
Copy link
Contributor Author

jiegillet commented Oct 25, 2023

Oh I still intend to keep rest-api, and I don't think having a difficult exercise is inherently a problem (I love those as a student), I'm just looking for another one that could help practicing decoders.
I don't think that rest-api is THAT complicated to understand if you read the description and the tests carefully though (I'll still try to make it clearer).

@ceddlyburge
Copy link
Contributor

Hmmm, none of those look that good. Maybe we could create a new exercise. Json encoding / decoding is something that people do find confusing when starting Elm, so it is a good idea. Maybe encoding a request to the github api (which is well known), and decoding a response?

@jiegillet
Copy link
Contributor Author

Creating a proper new practice exercise is way more work than I'm willing to do!
I guess we'll need a really good concept exercise :)

@mpizenberg
Copy link
Member

Maybe encoding a request to the github api (which is well known), and decoding a response?

Good idea to work on a concrete real-life thing. We'd have to rebuild the JS Value ourselves directly in the test though as obviously there is no outside world access in tests file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
x:action/create Work on something from scratch x:knowledge/intermediate Quite a bit of Exercism knowledge required x:module/concept Work on Concepts x:module/concept-exercise Work on Concept Exercises x:priority/high Has a higher priority than other issues x:size/large Large amount of work x:type/content Work on content (e.g. exercises, concepts)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants