apply suggestions and fix remaining haddock suggestions

This commit is contained in:
Emily Martins 2022-03-24 15:43:21 +01:00
parent 210a6195b6
commit 633c3bea9e
10 changed files with 70 additions and 34 deletions

View file

@ -9,7 +9,6 @@ module Agora.SafeMoney (
-- * Types
MoneyClass,
PDiscrete,
Discrete,
-- * Utility functions
paddDiscrete,
@ -44,11 +43,11 @@ import Plutarch.Monadic qualified as P
--------------------------------------------------------------------------------
import Agora.Utils
import Agora.Utils (passetClassValueOf, psingletonValue)
--------------------------------------------------------------------------------
-- | Type-level unique identifier for an `AssetClass`
-- | Type-level unique identifier for an 'Plutus.V1.Ledger.Value.AssetClass'
type MoneyClass =
( -- AssetClass
Symbol
@ -63,10 +62,6 @@ newtype PDiscrete (mc :: MoneyClass) (s :: S)
= PDiscrete (Term s PInteger)
deriving (PlutusType, PIsData, PEq, POrd) via (DerivePNewtype (PDiscrete mc) PInteger)
newtype Discrete (mc :: MoneyClass)
= Discrete Integer
deriving stock (Show)
-- | Check if one 'PDiscrete' is greater than another.
pgeqDiscrete :: forall (mc :: MoneyClass) (s :: S). Term s (PDiscrete mc :--> PDiscrete mc :--> PBool)
pgeqDiscrete = phoistAcyclic $
@ -75,7 +70,7 @@ pgeqDiscrete = phoistAcyclic $
PDiscrete y' <- pmatch y
y' #<= x'
-- | Conjure zero discrete unit for any moneyclass
-- | Returns a zero-value 'PDiscrete' unit for any 'MoneyClass'.
pzeroDiscrete :: forall (mc :: MoneyClass) (s :: S). Term s (PDiscrete mc)
pzeroDiscrete = phoistAcyclic $ pcon (PDiscrete 0)
@ -114,7 +109,8 @@ pvalueDiscrete = phoistAcyclic $
# f
{- | Get a `PValue` from a `PDiscrete`.
__NOTE__: `pdiscreteValue` after `pvalueDiscrete` loses information
__NOTE__: `pdiscreteValue` after `pvalueDiscrete` is not a round-trip.
It filters for a particular 'MoneyClass'.
-}
pdiscreteValue ::
forall (moneyClass :: MoneyClass) (ac :: Symbol) (n :: Symbol) (scale :: Nat) s.