Stock: Stock-style deriving via coercion, with no Generic

A package for extensible compile-time deriving: stock: Stock-style deriving via coercion, with no Generic

More information: Reddit - Please wait for verification

10 Likes

Wow, this is as verbose as writing a function manually, except it needs no underlying library implementing [and documenting] all of the helper functions, has no convenience of a function declaration, and forces a dependency on a GHC plugin.

In the case of aeson, where I’ve long complained there are no proper functions for writing parsers manually, this is akin to implementing them on top of Generics.

1 Like

You typically wouldn’t override all the fields. I’d use a library like this if I have a lot fields (10 or more perhaps) and only a few of them need overriding. And even if it would be equally long, I’d much prefer a declarative, correct by construction derived instance than code, no matter how clear, that I’d need to read to check for subtle mistakes, or would have to write boring tests for.

5 Likes

Stoked to derive some profunctors!

3 Likes

Whoa, this is awesome!