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

[Proposal] Support decoders #12

Open
vedantroy opened this issue Jun 14, 2020 · 0 comments
Open

[Proposal] Support decoders #12

vedantroy opened this issue Jun 14, 2020 · 0 comments

Comments

@vedantroy
Copy link
Owner

vedantroy commented Jun 14, 2020

typecheck.macro now supports arbitrary runtime constraints. However, it does not yet support decoders, which can deserialize values. It's complicated to implement this because, we can't arbitrarily mutate the input. For example:

x => {
  // Obviously this doesn't affect the value of the passed in parameter 
  // outside of this function
  x = 3
}

We can still mutate fields in the input. But, we can't re-assign the input itself. This doesn't just apply to the passed in input. We also need to deal with the following issue:

for (let x of some_array) {
     // this won't affect the actual element
    // in the array
     x = 5   
}

Of course, we can solve this issue by using a numerical for-loop, instead of a for-each loop, but that only solves this particular case.

Does anyone have thoughts?

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

No branches or pull requests

1 participant