Giter Club home page Giter Club logo

Comments (6)

andreasabel avatar andreasabel commented on June 2, 2024

Over to @tibbe and @hvr ...

from cassava.

phadej avatar phadej commented on June 2, 2024

How these instances would work? ToField/ FromField instances are "leaf"s: parsing a cell value into haskell value. What Generics would do there? I can think of deriving for newtypes, but these can be derived using newtype strategy anyway.

from cassava.

stevladimir avatar stevladimir commented on June 2, 2024

There can't exist reasonable encoding for all cases, e.g. for product types. But it exists for subset of sum types with constructors of 0- or 1-arity:

data Foo = Foo

data Foo = Bar | Baz Int

It's similar to UntaggedValue encoding from aeson. IIRC it should be possible to provide instances only for those cases without any dirty hacks.

from cassava.

phadej avatar phadej commented on June 2, 2024

Enum case makes sense. 1-arity is suspicious.

I'd suggest defining newtypes to be used with deriving via so the user tells what they want (instead of using clever generics trying to guess). That has an additional benefit that deriving mechanisms stay independent.

FWIW, I plan to make that change to aeson (in year or so, I'm not keen to break people too often).

from cassava.

stevladimir avatar stevladimir commented on June 2, 2024

Enum case makes sense. 1-arity is suspicious.

I'd suggest defining newtypes to be used with deriving via so the user tells what they want (instead of using clever generics trying to guess). That has an additional benefit that deriving mechanisms stay independent.

FWIW, I plan to make that change to aeson (in year or so, I'm not keen to break people too often).

I think we can select precisely which instances to allow (see PR).
It works only for 'single nullary' or 'sum with 0,1 constructors' types and doesn't allow deriving for newtypes.
Actually, another option could be not adding default method at all, so user would have to write instance explicitly in case of such need.

from cassava.

stevladimir avatar stevladimir commented on June 2, 2024

FWIW, I plan to make that change to aeson (in year or so, I'm not keen to break people too often).

Yeah, I like the idea. Current behavior is slightly confusing

from cassava.

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.