Skip to content
This repository has been archived by the owner on Aug 11, 2022. It is now read-only.

Need an Integer -> Maybe Positive function #219

Open
blamario opened this issue May 3, 2022 · 1 comment
Open

Need an Integer -> Maybe Positive function #219

blamario opened this issue May 3, 2022 · 1 comment

Comments

@blamario
Copy link

blamario commented May 3, 2022

https://github.com/Liqwid-Labs/plutus-extra/blob/master/plutus-numeric/src/PlutusTx/Positive.hs doesn't export any way to construct a Positive value except from a literal, using the quasiquoter. I'm currently using a ridiculous workaround of

toPositive :: Integer -> Positive
toPositive = unsafeFromBuiltinData . toBuiltinData

(in this case I ensure the argument is positive beforehand).

Alternatively, I could use

nonZero :: Natural -> Maybe Positive
@kozross
Copy link
Contributor

kozross commented May 3, 2022

I feel having conversions out of both Integer and Natural makes some sense.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants
@blamario @kozross and others