tweag / cooked-validators

MIT License
39 stars 11 forks source link

Default instance for PrettyCooked #242

Closed gabrielhdt closed 1 year ago

gabrielhdt commented 1 year ago

When definining PrettyCooked instances, calling recursively prettyCookedOpt on substructures is, I believe, quite natural. Some structures have Pretty instances but no PrettyCooked instances, hence we must call Prettyprinter.pretty instead of Cooked.prettyCookedOpt. If we don't, we get

No instance for (Cooked.PrettyCooked a) arising from the use of Cooked.prettyCookedOpt

Would it be possible to have Prettyprinter.pretty as the default instance of Cooked.prettyCookedOpt?

florentc commented 1 year ago

I agree this would be very convenient but if we define prettyCooked = pretty by default then we lose the current also-convenient-default where prettyCooked = prettyCookedOpt def. As for instance Pretty a => PrettyCooked a where prettyCooked = pretty, it leads to undecidable instances.

Usually, Plutus' Pretty instances are not that pretty (e.g. values, addresses). We should probably provide more instances in Cooked.Pretty for common types we often have to display.