Giter Club home page Giter Club logo

Comments (8)

natefaubion avatar natefaubion commented on June 8, 2024 1

Not sure if this helps you, but yoga-json is able to parse BigInt by passing a reviver function to JSON.parse.

Reviver functions don’t help here because it’s already a JSON Number. Reviver functions can’t recover the original JSON syntax in order to load a Number as a BigInt without losing precision.

from purescript.

sigma-andex avatar sigma-andex commented on June 8, 2024

It's not possible for tools like purescript-backend-optimizer to parse CoreFn JSON for backends which use unbounded integers with any of the stock JSON tooling available in the PureScript ecosystem as they all rely on builtin JSON.parse.

Not sure if this helps you, but yoga-json is able to parse BigInt by passing a reviver function to JSON.parse.

from purescript.

michaelficarra avatar michaelficarra commented on June 8, 2024

@natefaubion You may be interested in the Stage 3 proposal JSON.parse source text access which makes this possible through revivers. Stage 3 means recommended for implementation, and it is already available in Chrome stable.

from purescript.

garyb avatar garyb commented on June 8, 2024

Very cool!

from purescript.

JordanMartinez avatar JordanMartinez commented on June 8, 2024

@natefaubion You may be interested in the Stage 3 proposal JSON.parse source text access which makes this possible through revivers. Stage 3 means recommended for implementation, and it is already available in Chrome stable.

I still think it would be easier to just encode the value as a String.

from purescript.

JordanMartinez avatar JordanMartinez commented on June 8, 2024

@natefaubion While this issue is for an Integer value, should the same be done on a Number value, too?

from purescript.

natefaubion avatar natefaubion commented on June 8, 2024

I don't think so. Number values are Double which are IEEE floats, same as JS, so there's no precision issue.

from purescript.

anttih avatar anttih commented on June 8, 2024

This might be a slightly different incarnation of this issue I just came across while compiling the integers test suite using backend-optimizer (thus using corefn as input). The PS literal -2147483648 gets compiled to (negate 2147483648). That positive number literal doesn't fit the 32-bit Integer once it's converted to int with 2147483648|0. Changing the JSON representation to a string wouldn't actually help if the negative literal gets compiled to negate x, the damage is already done in the corefn.

from purescript.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.