True, but "batshit conservatives" won't do that, or will mess themselves if you do that, rather than making some kind of "Object-Whatever-Mapping" model and annotations.
But that's what I would do (at least in Java) for this kind of transient transfer object, if left to my own devices.
"deriving" is compile time; "Generic" is runtime inspection of the shape of a value (in terms of constructor applications). Something (at least vaguely) similar to Generic exists in many statically typed languages - including (IIRC, IIUC) Java and Go.
> Something (at least vaguely) similar to Generic exists in many statically typed languages - including (IIRC, IIUC) Java and Go.
Sure—but it's in spite of static typing, not because of it. You certainly give up any guarantees of avoiding runtime errors by detecting typing issues at compile time.
Sure, it's orthogonal to static typing (I wouldn't quite say "in spite of"). I wasn't trying to weigh in on the general topic, just to clarify what was happening where.
Not if you structure your data using an appropriate data structure, like a map. After all, this is all structs in dynamic languages are.
> A specific example might be "serialize this json type without having to annotate the fields with how to serialize them".
Aeson does this safely and statically using Haskell's powerful static Generics.
You can get named fields like