Code Monkey home page Code Monkey logo

Comments (6)

kolektiv avatar kolektiv commented on August 20, 2024

If we're going to have a fromJson CE (not a bad idea) would it make sense to introduce a toJson CE as well? The json CE would probably remain as a more "general" CE perhaps...

from chiron.

neoeinstein avatar neoeinstein commented on August 20, 2024

Yeah. I've just been re-looking at the Encoder<'a> type and thinking that it should also accept in the Json context instead of just the function it is now, so as to support "mixin" encoders. If so, then that leads to a toJson {} CE to support that. We could still have the json {} CE supported. Though I'm of two minds on retiring it, I'll default to keeping it supported.

from chiron.

kolektiv avatar kolektiv commented on August 20, 2024

The json {} CE does support more than just mapping to/from. With the Json.Optic.* support, etc. it supports querying and modification of JSON structures. There is an argument as to whether that's needed outside of a mapping context, but it does so at the moment...

from chiron.

neoeinstein avatar neoeinstein commented on August 20, 2024

Right. I can see that. Maybe I just haven't had a use case for doing reading during a ToJson or writing during a FromJson. The Json.Optic.* support is definitely still going to be useful. This may be something that I need to throw against the wall to really see what it looks like.

from chiron.

neoeinstein avatar neoeinstein commented on August 20, 2024

Ok, I can see a reason for the json {} CE. It exists as a composition of the "state" and "either" monads. What we really need is to "run" the CE. The CE needs to be extended so that it can bind to Encoders and Decoders. That would allow the more direct serialization/deserialization method to live along side the more general-purpose json {} method.

from chiron.

kolektiv avatar kolektiv commented on August 20, 2024

Yeah that sounds about right. Your point about reading in a ToJson or writing in a FromJson is completely valid - optics are just general like that. It'll be interesting to see how it works out - I can see ending up with two special case CEs and a general "work with JSON" CE - that might not be a bad thing (I don't tend to use the CEs anyway, but I know they are used).

Saying that does raise one issue in my head. At the moment there's only one type signature for all operations. Breaking that down in to multiple may make the maintenance of operators more complex - you would potentially introduce a requirement to have separate operators for each type. One way round that might be statically resolved operators, but it remains to be seen...

from chiron.

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.