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

Special Nats #205

Open
pdavidow opened this issue Mar 28, 2022 · 6 comments
Open

Special Nats #205

pdavidow opened this issue Mar 28, 2022 · 6 comments
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed question Further information is requested

Comments

@pdavidow
Copy link

AFAIK, Nat >= 1
But I also want to specify Nat >= 0; as well as Nat >= 2.
Is this currently possible? If not, please consider as enhancements.

@re-xyr
Copy link
Contributor

re-xyr commented Mar 28, 2022

Note that in plutus-numeric, Naturals are always greater than 0 and Positives are always greater than 1, so the only thing we don't have is naturals >= 2. It appears to me that it's pretty ad-hoc (unlike >=0 and >=1, which are "canonical" in some senses). It may be possible for us to have some data NatGreaterThan (n :: GHC.TypeLits.Natural), but I'm not sure if that will be easy enough to use. What are your use cases for such a type?

@kozross
Copy link
Contributor

kozross commented Mar 28, 2022

It's also worth mentioning that on-chain, we can't have 'type-level tags' of this form at all.

@kozross kozross added the question Further information is requested label Mar 28, 2022
@pdavidow
Copy link
Author

pdavidow commented Mar 28, 2022

Note that in plutus-numeric, Naturals are always greater than 0 and Positives are always greater than 1, so the only thing we don't have is naturals >= 2. It appears to me that it's pretty ad-hoc (unlike >=0 and >=1, which are "canonical" in some senses). It may be possible for us to have some data NatGreaterThan (n :: GHC.TypeLits.Natural), but I'm not sure if that will be easy enough to use. What are your use cases for such a type?

My use-case is a fancy datatype purely on the offchain side, for which I can easily wrap a newtype on Positive with a smart constructor.

data EqualIntervalSpec = EqualIntervalSpec PosGE2 Duration
newtype PosGE2 = PosGE2 Positive
mkPosGE2 :: Positive -> Maybe PosGE2

Minimum interval amount is 2

@pdavidow
Copy link
Author

Naturals are always greater than 0 and Positives are always greater than 1

Where is this documented? I somehow missed it.

@kozross
Copy link
Contributor

kozross commented Mar 29, 2022

Naturals are always greater than 0 and Positives are always greater than 1

Where is this documented? I somehow missed it.

Here and here.

Insofar as a 'greater than 1' numeric data type is concerned, it's unlikely we'll be implementing such a thing soon.

@kozross kozross added enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed labels Mar 29, 2022
@re-xyr
Copy link
Contributor

re-xyr commented Mar 30, 2022

Where is this documented? I somehow missed it.

Sorry! I meant "greater than or equal to". Naturals are >=0 and Positives are >= 1.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed question Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants
@pdavidow @kozross @re-xyr and others