plutus icon indicating copy to clipboard operation
plutus copied to clipboard

Fixed point arithmetic and `Data.Fixed`

Open mgajda opened this issue 3 years ago • 1 comments

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.Fixed for 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.Ada datatype is best example of how each such type needs to be implemented manually.

mgajda avatar Dec 08 '21 22:12 mgajda

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.

michaelpj avatar Dec 09 '21 10:12 michaelpj

Closing as a duplicate of #4537.

effectfully avatar Jan 31 '23 23:01 effectfully