IntersectMBO / IntersectMBO/plutus

Derivation of Ord type class

Open
#4,273 2 comments 0 reactions 0 assignees View on GitHub
Good first issue Low priority status: triaged
Dominant language
Haskell
Stars
1.6k
Forks
508
Avg merge
3d 10h
Merged PRs (30d)
22

Description

## Describe the feature you'd like

`PlutusTx.Ord` does not have automatic derivation mechanism
which means a lot of error-prone work for large algebraic datatypes.

It would be nice to have `TemplateHaskell` derivation `deriveOrd` just like `makeLift`
or a mechanism based on `Generic`.

## Describe alternatives you've considered

Alternative is to manually derive `Ord` instances.
It is not only a lot of manual work (with 20 constructors we see about 190 comparisons),
but it is also error prone.
Since this work also needs to be audited, any such work may also lead to slight increase in cost of the smart contract security.

## Describe the approach you would take to implement this

I would follow `makeLift` as a template, and define the `deriveOrd` in a similar fashion.
Please let me know if you have a better plan.

## Additional context / screenshots

Several type classes as fundamental for best practice of Haskell programming and derived automatically for ADTs:

* `Eq` (which can be derived from `Ord` and suffers from the same problem)
* `Enum`
* `Bounded`
* `Arbitrary`

Expansion of this work can serve to help maintain the best practices of using these without extra coding.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.