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

Add an example for Encoding and Decoding abilities #166

Merged
merged 2 commits into from
Apr 11, 2024

Conversation

lukewilliamboswell
Copy link
Collaborator

No description provided.

@faldor20
Copy link

Hey, I am slightly concerned that this shows a very inefficient way of decoding and encoding this type. I appreciate you may want to show how the internals work, but it's not really showing best practices. perhaps if we want to show complex encoding and decoding we should pick a type that should be decoded that way

eg: For the encoder it should probably look like this:

encodeItems : ItemKind -> Encoder fmt
encodeItems = \@ItemKind tag ->
    when tag is
        Text -> 1
        Method -> 2
        Function -> 3
        Constructor -> 4
        Field -> 5
        Variable -> 6
        Class -> 7
        Interface -> 8
        Module -> 9
    |>Encode.u8

bhansconnect
bhansconnect previously approved these changes Apr 11, 2024
Copy link
Collaborator

@bhansconnect bhansconnect left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is totally fine to merge as is, but some listed nit comments would be nice to address.

examples/EncodeDecode/main.roc Show resolved Hide resolved
examples/EncodeDecode/main.roc Outdated Show resolved Hide resolved
examples/EncodeDecode/main.roc Outdated Show resolved Hide resolved
@lukewilliamboswell
Copy link
Collaborator Author

Updated with @faldor20 changes, thanks ❤️ 🇦🇺 🦘 . I think this is a much improved example.

@lukewilliamboswell lukewilliamboswell merged commit 913d4e0 into main Apr 11, 2024
3 checks passed
@lukewilliamboswell lukewilliamboswell deleted the encode-decode branch April 11, 2024 04:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants