plutus
plutus copied to clipboard
Fixed point arithmetic and `Data.Fixed`
Describe the feature you'd like
Haskell has long enjoyed convenient fixed point arithmetic with Data.Fixed.
However, we cannot use Data.Fixed cannot use parametric precision at the moment, since the type with kinded argument is not supported.
Describe alternatives you've considered
Alternatives considered are:
- request support for kinded argument
- template haskell derivation of alternative
Data.Fixedfor each resolution - manually implement each case
Describe the approach you would take to implement this
Since fixed point arithmetic comes in many financial applications, I would like suggestions on the best way to tackle this problem in the long run.
Additional context / screenshots
Ledger.Adadatatype is best example of how each such type needs to be implemented manually.
Yeah, it's annoying that Data.Fixed is poly-kinded. That won't be supported any time soon. Manually implementing the N versions might be the simplest solution.
Closing as a duplicate of #4537.