zkFold / zkfold-base

ZkFold's Base library
https://zkfold.io
MIT License
17 stars 7 forks source link

Use Haskell's `Generic` deriving mechanism to improve instance deriving of `Symbolic` typeclasses #221

Open TurtlePU opened 3 months ago

TurtlePU commented 3 months ago

Currently, the story of deriving Symbolic typeclasses is as follows:

We can do better. Using Generic as described on this wiki page, we can do the following:

I would like to provide instances for SymbolicData and Conditional instead of default implementations because I do not expect them to have any other instances other than the ones we can generate via Generic. On the other hand, the rest of the typeclasses can have custom (or more performant) instances for user-defined datatypes; in addition, for SymbolicInput this can serve as an additional sanity-check if the datatype defined by the user is indeed qualified to be an input to the smart contract.

If there are any other suggestions, please comment.

TurtlePU commented 2 weeks ago

What about SymbolicInput, Conditional, Eq and Ord? Maybe we can split this issue then...