plutarch-1.9.0
Safe HaskellSafe-Inferred
LanguageGHC2021

Plutarch.Internal.Numeric

Synopsis

Types

data PPositive (s :: S) Source #

@since WIP

Instances

Instances details
PCountable PPositive Source #

@since WIP

Instance details

Defined in Plutarch.Enum

Methods

psuccessor :: forall (s :: S). Term s (PPositive :--> PPositive) Source #

psuccessorN :: forall (s :: S). Term s (PPositive :--> (PPositive :--> PPositive)) Source #

PEq PPositive Source #

@since WIP

Instance details

Defined in Plutarch.Internal.Numeric

Methods

(#==) :: forall (s :: S). Term s PPositive -> Term s PPositive -> Term s PBool Source #

PIsData PPositive Source #

@since WIP

Instance details

Defined in Plutarch.Internal.Numeric

Methods

pfromDataImpl :: forall (s :: S). Term s (PAsData PPositive) -> Term s PPositive Source #

pdataImpl :: forall (s :: S). Term s PPositive -> Term s PData Source #

PLiftable PPositive Source # 
Instance details

Defined in Plutarch.Internal.Numeric

PAdditiveSemigroup PPositive Source #

@since WIP

@since WIP

Instance details

Defined in Plutarch.Internal.Numeric

Methods

(#+) :: forall (s :: S). Term s PPositive -> Term s PPositive -> Term s PPositive Source #

pscalePositive :: forall (s :: S). Term s (PPositive :--> (PPositive :--> PPositive)) Source #

PMultiplicativeMonoid PPositive Source #

@since WIP

Instance details

Defined in Plutarch.Internal.Numeric

Methods

pone :: forall (s :: S). Term s PPositive Source #

PMultiplicativeSemigroup PPositive Source #

@since WIP

@since WIP

Instance details

Defined in Plutarch.Internal.Numeric

Methods

(#*) :: forall (s :: S). Term s PPositive -> Term s PPositive -> Term s PPositive Source #

ppowPositive :: forall (s :: S). Term s (PPositive :--> (PPositive :--> PPositive)) Source #

POrd PPositive Source #

@since WIP

Instance details

Defined in Plutarch.Internal.Numeric

Methods

(#<=) :: forall (s :: S). Term s PPositive -> Term s PPositive -> Term s PBool Source #

(#<) :: forall (s :: S). Term s PPositive -> Term s PPositive -> Term s PBool Source #

pmax :: forall (s :: S). Term s PPositive -> Term s PPositive -> Term s PPositive Source #

pmin :: forall (s :: S). Term s PPositive -> Term s PPositive -> Term s PPositive Source #

DerivePlutusType PPositive Source #

@since WIP

Instance details

Defined in Plutarch.Internal.Numeric

Associated Types

type DPTStrat PPositive Source #

PlutusType PPositive Source # 
Instance details

Defined in Plutarch.Internal.Numeric

Methods

pcon' :: forall (s :: S). PPositive s -> Term s (PInner PPositive) Source #

pmatch' :: forall (s :: S) (b :: PType). Term s (PInner PPositive) -> (PPositive s -> Term s b) -> Term s b Source #

PShow PPositive Source #

@since WIP

Instance details

Defined in Plutarch.Internal.Show

Methods

pshow' :: forall (s :: S). Bool -> Term s PPositive -> Term s PString Source #

PTryFrom PInteger PPositive Source #

@since WIP

Instance details

Defined in Plutarch.Internal.TryFrom

Associated Types

type PTryFromExcess PInteger PPositive :: PType Source #

Methods

ptryFrom' :: forall (s :: S) (r :: PType). Term s PInteger -> ((Term s PPositive, Reduce (PTryFromExcess PInteger PPositive s)) -> Term s r) -> Term s r Source #

PTryFrom PData (PAsData PPositive) Source #

@since WIP

Instance details

Defined in Plutarch.Internal.TryFrom

Associated Types

type PTryFromExcess PData (PAsData PPositive) :: PType Source #

Methods

ptryFrom' :: forall (s :: S) (r :: PType). Term s PData -> ((Term s (PAsData PPositive), Reduce (PTryFromExcess PData (PAsData PPositive) s)) -> Term s r) -> Term s r Source #

Generic (PPositive s) Source # 
Instance details

Defined in Plutarch.Internal.Numeric

Associated Types

type Rep (PPositive s) :: Type -> Type Source #

Methods

from :: PPositive s -> Rep (PPositive s) x Source #

to :: Rep (PPositive s) x -> PPositive s Source #

type AsHaskell PPositive Source #

@since WIP

Instance details

Defined in Plutarch.Internal.Numeric

type PlutusRepr PPositive Source # 
Instance details

Defined in Plutarch.Internal.Numeric

type DPTStrat PPositive Source # 
Instance details

Defined in Plutarch.Internal.Numeric

type PContravariant' PPositive Source # 
Instance details

Defined in Plutarch.Internal.Numeric

type PCovariant' PPositive Source # 
Instance details

Defined in Plutarch.Internal.Numeric

type PInner PPositive Source #

@since WIP

Instance details

Defined in Plutarch.Internal.Numeric

type PVariant' PPositive Source # 
Instance details

Defined in Plutarch.Internal.Numeric

type PTryFromExcess PInteger PPositive Source # 
Instance details

Defined in Plutarch.Internal.TryFrom

type PTryFromExcess PData (PAsData PPositive) Source # 
Instance details

Defined in Plutarch.Internal.TryFrom

type Rep (PPositive s) Source #

@since WIP

Instance details

Defined in Plutarch.Internal.Numeric

type Rep (PPositive s) = D1 ('MetaData "PPositive" "Plutarch.Internal.Numeric" "plutarch-1.9.0-FtN0mhIoM9oEvz7Q98pjWP" 'True) (C1 ('MetaCons "PPositive" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Term s PInteger))))

data Positive Source #

@since WIP

Instances

Instances details
Arbitrary Positive Source #

@since WIP

Instance details

Defined in Plutarch.Internal.Numeric

CoArbitrary Positive Source #

@since WIP

Instance details

Defined in Plutarch.Internal.Numeric

Methods

coarbitrary :: Positive -> Gen b -> Gen b

Function Positive Source #

@since WIP

Instance details

Defined in Plutarch.Internal.Numeric

Methods

function :: (Positive -> b) -> Positive :-> b

Show Positive Source #

@since WIP

Instance details

Defined in Plutarch.Internal.Numeric

Eq Positive Source #

@since WIP

Instance details

Defined in Plutarch.Internal.Numeric

Ord Positive Source #

@since WIP

Instance details

Defined in Plutarch.Internal.Numeric

Pretty Positive Source #

@since WIP

Instance details

Defined in Plutarch.Internal.Numeric

Methods

pretty :: Positive -> Doc ann

prettyList :: [Positive] -> Doc ann

Type classes

class PAdditiveSemigroup (a :: S -> Type) where Source #

The addition operation.

Laws

  1. x #+ y = y #+ x (commutativity of #+)
  2. x #+ (y #+ z) = (x #+ y) #+ z (associativity of #+)

If you define a custom pscalePositive, ensure the following also hold:

  1. pscalePositive # x # pone = x
  2. (pscalePositive # x # n) #+ (pscalePositive # x # m) = pscalePositive # x # (n #+ m)
  3. pscalePositive # (pscalePositive # x # n) # m = pscalePositive # x # (n #* m)

The default implementation ensures these laws are satisfied.

@since WIP

Minimal complete definition

Nothing

Methods

(#+) :: forall (s :: S). Term s a -> Term s a -> Term s a infix 6 Source #

default (#+) :: forall (s :: S). PAdditiveSemigroup (PInner a) => Term s a -> Term s a -> Term s a Source #

pscalePositive :: forall (s :: S). Term s (a :--> (PPositive :--> a)) Source #

This defaults to exponentiation-by-squaring, which in general is the best we can do.

Instances

Instances details
PAdditiveSemigroup PBuiltinBLS12_381_G1_Element Source #

@since WIP

Instance details

Defined in Plutarch.Internal.Numeric

PAdditiveSemigroup PBuiltinBLS12_381_G2_Element Source #

@since WIP

Instance details

Defined in Plutarch.Internal.Numeric

PAdditiveSemigroup PInteger Source #

@since WIP

Instance details

Defined in Plutarch.Internal.Numeric

Methods

(#+) :: forall (s :: S). Term s PInteger -> Term s PInteger -> Term s PInteger Source #

pscalePositive :: forall (s :: S). Term s (PInteger :--> (PPositive :--> PInteger)) Source #

PAdditiveSemigroup PPositive Source #

@since WIP

@since WIP

Instance details

Defined in Plutarch.Internal.Numeric

Methods

(#+) :: forall (s :: S). Term s PPositive -> Term s PPositive -> Term s PPositive Source #

pscalePositive :: forall (s :: S). Term s (PPositive :--> (PPositive :--> PPositive)) Source #

PAdditiveSemigroup PRational Source #

@since WIP

Instance details

Defined in Plutarch.Rational

Methods

(#+) :: forall (s :: S). Term s PRational -> Term s PRational -> Term s PRational Source #

pscalePositive :: forall (s :: S). Term s (PRational :--> (PPositive :--> PRational)) Source #

class PAdditiveSemigroup a => PAdditiveMonoid (a :: S -> Type) where Source #

The notion of zero, as well as a (kind of) reversal of pscalePositive, similar to floor division by positive integers.

Laws

  1. pzero #+ x = x (pzero is the identity of #+)
  2. pscalePositive # pzero # n = pzero (pzero does not scale up)

@since WIP

Methods

pzero :: forall (s :: S). Term s a Source #

Instances

Instances details
PAdditiveMonoid PBuiltinBLS12_381_G1_Element Source #

@since WIP

Instance details

Defined in Plutarch.Internal.Numeric

Methods

pzero :: forall (s :: S). Term s PBuiltinBLS12_381_G1_Element Source #

PAdditiveMonoid PBuiltinBLS12_381_G2_Element Source #

@since WIP

Instance details

Defined in Plutarch.Internal.Numeric

Methods

pzero :: forall (s :: S). Term s PBuiltinBLS12_381_G2_Element Source #

PAdditiveMonoid PInteger Source #

@since WIP

Instance details

Defined in Plutarch.Internal.Numeric

Methods

pzero :: forall (s :: S). Term s PInteger Source #

PAdditiveMonoid PRational Source #

@since WIP

Instance details

Defined in Plutarch.Rational

Methods

pzero :: forall (s :: S). Term s PRational Source #

class PAdditiveMonoid a => PAdditiveGroup (a :: S -> Type) where Source #

The notion of additive inverses, and the subtraction operation.

Laws

If you define pnegate, the following laws must hold:

  1. (pnegate # x) #+ x = pzero (pnegate is an additive inverse)
  2. pnegate #$ pnegate # x = x (pnegate is self-inverting)

If you define #-, the following law must hold:

  1. x #- x = pzero

Additionally, the following 'consistency laws' must hold. Default implementations of both pnegate and #- uphold these.

  1. pnegate # x = pzero #- x
  2. x #- y = x #+ (pnegate # y)

Lastly, if you define a custom pscaleInteger, the following laws must hold:

  1. pscaleInteger # x # pzero = pzero
  2. pscaleInteger # x #$ pnegate y = pnegate #$ pscaleInteger # x # y

@since WIP

Minimal complete definition

pnegate | (#-)

Methods

pnegate :: forall (s :: S). Term s (a :--> a) Source #

(#-) :: forall (s :: S). Term s a -> Term s a -> Term s a infix 6 Source #

pscaleInteger :: forall (s :: S). Term s (a :--> (PInteger :--> a)) Source #

Instances

Instances details
PAdditiveGroup PBuiltinBLS12_381_G1_Element Source #

@since WIP

Instance details

Defined in Plutarch.Internal.Numeric

PAdditiveGroup PBuiltinBLS12_381_G2_Element Source #

@since WIP

Instance details

Defined in Plutarch.Internal.Numeric

PAdditiveGroup PInteger Source #

@since WIP

@since WIP

Instance details

Defined in Plutarch.Internal.Numeric

Methods

pnegate :: forall (s :: S). Term s (PInteger :--> PInteger) Source #

(#-) :: forall (s :: S). Term s PInteger -> Term s PInteger -> Term s PInteger Source #

pscaleInteger :: forall (s :: S). Term s (PInteger :--> (PInteger :--> PInteger)) Source #

PAdditiveGroup PRational Source #

@since WIP

Instance details

Defined in Plutarch.Rational

Methods

pnegate :: forall (s :: S). Term s (PRational :--> PRational) Source #

(#-) :: forall (s :: S). Term s PRational -> Term s PRational -> Term s PRational Source #

pscaleInteger :: forall (s :: S). Term s (PRational :--> (PInteger :--> PRational)) Source #

class PMultiplicativeSemigroup (a :: S -> Type) where Source #

The multiplication operation.

Laws

  1. x #* (y #* z) = (x #* y) #* z (associativity of #*)

If you define a custom ppowPositive, ensure the following also hold:

  1. ppowPositive # x # pone = x
  2. (ppowPositive # x # n) #* (ppowPositive # x # m) = pscalePositive # x # (n #+ m)
  3. ppowPositive # (ppowPositive # x # n) # m = pscalePositive # x # (n #* m)

The default implementation ensures these laws are satisfied.

Note

Unlike PAdditiveSemigroup, the multiplication operation doesn't need to be commutative. Currently, all Plutarch-provided instances are, but this need not be true for other instances.

@since WIP

Minimal complete definition

Nothing

Methods

(#*) :: forall (s :: S). Term s a -> Term s a -> Term s a infix 6 Source #

default (#*) :: forall (s :: S). PMultiplicativeSemigroup (PInner a) => Term s a -> Term s a -> Term s a Source #

ppowPositive :: forall (s :: S). Term s (a :--> (PPositive :--> a)) Source #

Instances

Instances details
PMultiplicativeSemigroup PInteger Source #

@since WIP

Instance details

Defined in Plutarch.Internal.Numeric

Methods

(#*) :: forall (s :: S). Term s PInteger -> Term s PInteger -> Term s PInteger Source #

ppowPositive :: forall (s :: S). Term s (PInteger :--> (PPositive :--> PInteger)) Source #

PMultiplicativeSemigroup PPositive Source #

@since WIP

@since WIP

Instance details

Defined in Plutarch.Internal.Numeric

Methods

(#*) :: forall (s :: S). Term s PPositive -> Term s PPositive -> Term s PPositive Source #

ppowPositive :: forall (s :: S). Term s (PPositive :--> (PPositive :--> PPositive)) Source #

PMultiplicativeSemigroup PRational Source #

@since WIP

Instance details

Defined in Plutarch.Rational

Methods

(#*) :: forall (s :: S). Term s PRational -> Term s PRational -> Term s PRational Source #

ppowPositive :: forall (s :: S). Term s (PRational :--> (PPositive :--> PRational)) Source #

class PMultiplicativeSemigroup a => PMultiplicativeMonoid (a :: S -> Type) where Source #

The notion of one (multiplicative identity).

Laws

  1. pone #* x = x (pone is the left identity of #*)
  2. x #* pone = x (pone is the right identity of #*)

@since WIP

Methods

pone :: forall (s :: S). Term s a Source #

Instances

Instances details
PMultiplicativeMonoid PInteger Source #

@since WIP

Instance details

Defined in Plutarch.Internal.Numeric

Methods

pone :: forall (s :: S). Term s PInteger Source #

PMultiplicativeMonoid PPositive Source #

@since WIP

Instance details

Defined in Plutarch.Internal.Numeric

Methods

pone :: forall (s :: S). Term s PPositive Source #

PMultiplicativeMonoid PRational Source #

@since WIP

Instance details

Defined in Plutarch.Rational

Methods

pone :: forall (s :: S). Term s PRational Source #

class (PAdditiveGroup a, PMultiplicativeMonoid a) => PRing (a :: S -> Type) where Source #

Laws

  1. pfromInteger 0 = pzero
  2. pfromInteger 1 = pone
  3. pfromInteger (x + y) = pfromInteger x #+ pfromInteger y
  4. pfromInteger (x * y) = pfromInteger x #* pfromInteger y

Additionally, the following 'interaction laws' must hold between the instances of PAdditiveGroup and PMultiplicativeMonoid for a:

  1. x #* (y #+ z) = (x #* y) #+ (x #* z) (#* left-distributes over #+)
  2. (y #+ z) #* x = (y #* x) #+ (z #* x) (#* right-distributes over #+)

@since WIP

Minimal complete definition

Nothing

Methods

pfromInteger :: forall (s :: S). Integer -> Term s a Source #

default pfromInteger :: forall (s :: S). PRing (PInner a) => Integer -> Term s a Source #

Instances

Instances details
PRing PInteger Source #

@since WIP

Instance details

Defined in Plutarch.Internal.Numeric

Methods

pfromInteger :: forall (s :: S). Integer -> Term s PInteger Source #

PRing PRational Source #

@since WIP

Instance details

Defined in Plutarch.Rational

Methods

pfromInteger :: forall (s :: S). Integer -> Term s PRational Source #

class (PRing a, POrd a) => PIntegralDomain (a :: S -> Type) where Source #

Laws

Pedantry note

Technically, the requirements here are too strong: we demand an ordered ring, which integral domains don't necessarily have to be. However, in our case, our hand is forced by expected semantics: in abstract algebra, both the absolute value and the signum are real numbers (which are always totally ordered) but in our case, both must be elements of the integral domain itself. Thus, in order for the laws to make any sense, we have to ensure a total order on the integral domain. Since all of our integral domains are 'at least as big' as the integers, this doesn't pose a huge problem.

@since WIP

Minimal complete definition

Nothing

Methods

psignum :: forall (s :: S). Term s (a :--> a) Source #

default psignum :: forall (s :: S). Term s (a :--> a) Source #

pabs :: forall (s :: S). Term s (a :--> a) Source #

default pabs :: forall (s :: S). Term s (a :--> a) Source #

Instances

Instances details
PIntegralDomain PInteger Source #

@since WIP

Instance details

Defined in Plutarch.Internal.Numeric

Methods

psignum :: forall (s :: S). Term s (PInteger :--> PInteger) Source #

pabs :: forall (s :: S). Term s (PInteger :--> PInteger) Source #

PIntegralDomain PRational Source #

@since WIP

Instance details

Defined in Plutarch.Rational

Methods

psignum :: forall (s :: S). Term s (PRational :--> PRational) Source #

pabs :: forall (s :: S). Term s (PRational :--> PRational) Source #

Functions

ptryPositive :: forall (s :: S). Term s (PInteger :--> PPositive) Source #

Partial version of PPositive. Errors if argument is zero.

@since WIP

ppositive :: Term s (PInteger :--> PMaybe PPositive) Source #

Build a PPositive from a PInteger. Yields PNothing if argument is zero.

pbySquaringDefault :: forall (a :: S -> Type) (s :: S). (forall (s' :: S). Term s' a -> Term s' a -> Term s' a) -> Term s (a :--> (PPositive :--> a)) Source #

A default implementation of exponentiation-by-squaring with a strictly-positive exponent.

Important note

This implementation assumes that the operation argument is associative.

@since WIP

pdiv :: forall (s :: S). Term s (PInteger :--> (PInteger :--> PInteger)) Source #

@since WIP

pmod :: forall (s :: S). Term s (PInteger :--> (PInteger :--> PInteger)) Source #

@since WIP

pquot :: forall (s :: S). Term s (PInteger :--> (PInteger :--> PInteger)) Source #

@since WIP

prem :: forall (s :: S). Term s (PInteger :--> (PInteger :--> PInteger)) Source #

@since WIP

Orphan instances

PIntegralDomain a => Num (Term s a) Source # 
Instance details

Methods

(+) :: Term s a -> Term s a -> Term s a Source #

(-) :: Term s a -> Term s a -> Term s a Source #

(*) :: Term s a -> Term s a -> Term s a Source #

negate :: Term s a -> Term s a Source #

abs :: Term s a -> Term s a Source #

signum :: Term s a -> Term s a Source #

fromInteger :: Integer -> Term s a Source #