Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Encode, decode number for variants alias #64

Merged
merged 4 commits into from
Nov 19, 2023
Merged

Conversation

mununki
Copy link
Member

@mununki mununki commented Nov 19, 2023

#62
This PR enables the encoding, decoding the number for variants. Responding to the representation Js.Json.Number(float) in the compiler, only float value can be handled.

@spice
type t = | @spice.as(1.0) One | @spice.as(2.0) Two

let encoded = One->t_encode // 1.0
let decoded = Js.Json.number(1.0)->t_decode // One

@mununki mununki merged commit 7d40053 into main Nov 19, 2023
@mununki mununki deleted the decode-number-variants branch November 19, 2023 12:25
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant