{-# OPTIONS_GHC -Wno-orphans #-}

-- Mirrors the equivalent V1 module in plutus-ledger-api
module Plutarch.LedgerApi.V1.Time (
  -- * Type
  PPosixTime (..),

  -- * Functions
  pposixTime,
  unPPosixTime,
) where

import Plutarch.Builtin (PDataNewtype (PDataNewtype))
import Plutarch.Enum (
  PCountable (psuccessor, psuccessorN),
  PEnumerable (ppredecessor, ppredecessorN),
 )
import Plutarch.Internal.Lift (DeriveDataPLiftable)
import Plutarch.LedgerApi.Utils (Mret)
import Plutarch.Num (PNum (pabs, pfromInteger, pnegate, psignum, (#*), (#+), (#-)))
import Plutarch.Prelude
import Plutarch.Reducible (Reduce)
import Plutarch.TryFrom (PTryFrom (PTryFromExcess, ptryFrom'))
import Plutarch.Unsafe (punsafeCoerce)
import PlutusLedgerApi.V1 qualified as Plutus

-- | @since 2.0.0
newtype PPosixTime (s :: S) = PPosixTime (Term s (PDataNewtype PInteger))
  deriving stock
    ( -- | @since 2.0.0
      (forall x. PPosixTime s -> Rep (PPosixTime s) x)
-> (forall x. Rep (PPosixTime s) x -> PPosixTime s)
-> Generic (PPosixTime s)
forall x. Rep (PPosixTime s) x -> PPosixTime s
forall x. PPosixTime s -> Rep (PPosixTime s) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall (s :: S) x. Rep (PPosixTime s) x -> PPosixTime s
forall (s :: S) x. PPosixTime s -> Rep (PPosixTime s) x
$cfrom :: forall (s :: S) x. PPosixTime s -> Rep (PPosixTime s) x
from :: forall x. PPosixTime s -> Rep (PPosixTime s) x
$cto :: forall (s :: S) x. Rep (PPosixTime s) x -> PPosixTime s
to :: forall x. Rep (PPosixTime s) x -> PPosixTime s
Generic
    )
  deriving anyclass
    ( -- | @since 2.0.0
      (forall (s :: S). PPosixTime s -> Term s (PInner PPosixTime))
-> (forall (s :: S) (b :: PType).
    Term s (PInner PPosixTime)
    -> (PPosixTime s -> Term s b) -> Term s b)
-> PlutusType PPosixTime
forall (s :: S). PPosixTime s -> Term s (PInner PPosixTime)
forall (s :: S) (b :: PType).
Term s (PInner PPosixTime)
-> (PPosixTime s -> Term s b) -> Term s b
forall (a :: PType).
(forall (s :: S). a s -> Term s (PInner a))
-> (forall (s :: S) (b :: PType).
    Term s (PInner a) -> (a s -> Term s b) -> Term s b)
-> PlutusType a
$cpcon' :: forall (s :: S). PPosixTime s -> Term s (PInner PPosixTime)
pcon' :: forall (s :: S). PPosixTime s -> Term s (PInner PPosixTime)
$cpmatch' :: forall (s :: S) (b :: PType).
Term s (PInner PPosixTime)
-> (PPosixTime s -> Term s b) -> Term s b
pmatch' :: forall (s :: S) (b :: PType).
Term s (PInner PPosixTime)
-> (PPosixTime s -> Term s b) -> Term s b
PlutusType
    , -- | @since 2.0.0
      (forall (s :: S). Term s (PAsData PPosixTime) -> Term s PPosixTime)
-> (forall (s :: S). Term s PPosixTime -> Term s PData)
-> PIsData PPosixTime
forall (s :: S). Term s (PAsData PPosixTime) -> Term s PPosixTime
forall (s :: S). Term s PPosixTime -> Term s PData
forall (a :: PType).
(forall (s :: S). Term s (PAsData a) -> Term s a)
-> (forall (s :: S). Term s a -> Term s PData) -> PIsData a
$cpfromDataImpl :: forall (s :: S). Term s (PAsData PPosixTime) -> Term s PPosixTime
pfromDataImpl :: forall (s :: S). Term s (PAsData PPosixTime) -> Term s PPosixTime
$cpdataImpl :: forall (s :: S). Term s PPosixTime -> Term s PData
pdataImpl :: forall (s :: S). Term s PPosixTime -> Term s PData
PIsData
    , -- | @since 2.0.0
      (forall (s :: S).
 Term s PPosixTime -> Term s PPosixTime -> Term s PBool)
-> PEq PPosixTime
forall (s :: S).
Term s PPosixTime -> Term s PPosixTime -> Term s PBool
forall (t :: PType).
(forall (s :: S). Term s t -> Term s t -> Term s PBool) -> PEq t
$c#== :: forall (s :: S).
Term s PPosixTime -> Term s PPosixTime -> Term s PBool
#== :: forall (s :: S).
Term s PPosixTime -> Term s PPosixTime -> Term s PBool
PEq
    , -- | @since 2.0.0
      PEq PPosixTime
PEq PPosixTime =>
(forall (s :: S).
 Term s PPosixTime -> Term s PPosixTime -> Term s PBool)
-> (forall (s :: S).
    Term s PPosixTime -> Term s PPosixTime -> Term s PBool)
-> (forall (s :: S).
    Term s PPosixTime -> Term s PPosixTime -> Term s PBool)
-> (forall (s :: S).
    Term s PPosixTime -> Term s PPosixTime -> Term s PBool)
-> PPartialOrd PPosixTime
forall (s :: S).
Term s PPosixTime -> Term s PPosixTime -> Term s PBool
forall (t :: PType).
PEq t =>
(forall (s :: S). Term s t -> Term s t -> Term s PBool)
-> (forall (s :: S). Term s t -> Term s t -> Term s PBool)
-> (forall (s :: S). Term s t -> Term s t -> Term s PBool)
-> (forall (s :: S). Term s t -> Term s t -> Term s PBool)
-> PPartialOrd t
$c#<= :: forall (s :: S).
Term s PPosixTime -> Term s PPosixTime -> Term s PBool
#<= :: forall (s :: S).
Term s PPosixTime -> Term s PPosixTime -> Term s PBool
$c#< :: forall (s :: S).
Term s PPosixTime -> Term s PPosixTime -> Term s PBool
#< :: forall (s :: S).
Term s PPosixTime -> Term s PPosixTime -> Term s PBool
$c#>= :: forall (s :: S).
Term s PPosixTime -> Term s PPosixTime -> Term s PBool
#>= :: forall (s :: S).
Term s PPosixTime -> Term s PPosixTime -> Term s PBool
$c#> :: forall (s :: S).
Term s PPosixTime -> Term s PPosixTime -> Term s PBool
#> :: forall (s :: S).
Term s PPosixTime -> Term s PPosixTime -> Term s PBool
PPartialOrd
    , -- | @since 2.0.0
      PPartialOrd PPosixTime
PPartialOrd PPosixTime =>
(forall (s :: S).
 Term s PPosixTime -> Term s PPosixTime -> Term s PPosixTime)
-> (forall (s :: S).
    Term s PPosixTime -> Term s PPosixTime -> Term s PPosixTime)
-> POrd PPosixTime
forall (s :: S).
Term s PPosixTime -> Term s PPosixTime -> Term s PPosixTime
forall (t :: PType).
PPartialOrd t =>
(forall (s :: S). Term s t -> Term s t -> Term s t)
-> (forall (s :: S). Term s t -> Term s t -> Term s t) -> POrd t
$cpmax :: forall (s :: S).
Term s PPosixTime -> Term s PPosixTime -> Term s PPosixTime
pmax :: forall (s :: S).
Term s PPosixTime -> Term s PPosixTime -> Term s PPosixTime
$cpmin :: forall (s :: S).
Term s PPosixTime -> Term s PPosixTime -> Term s PPosixTime
pmin :: forall (s :: S).
Term s PPosixTime -> Term s PPosixTime -> Term s PPosixTime
POrd
    , -- | @since 2.0.0
      (forall (s :: S). Bool -> Term s PPosixTime -> Term s PString)
-> PShow PPosixTime
forall (s :: S). Bool -> Term s PPosixTime -> Term s PString
forall (t :: PType).
(forall (s :: S). Bool -> Term s t -> Term s PString) -> PShow t
$cpshow' :: forall (s :: S). Bool -> Term s PPosixTime -> Term s PString
pshow' :: forall (s :: S). Bool -> Term s PPosixTime -> Term s PString
PShow
    )

-- | @since WIP
instance PCountable PPosixTime where
  {-# INLINEABLE psuccessor #-}
  psuccessor :: forall (s :: S). Term s (PPosixTime :--> PPosixTime)
psuccessor = (forall (s :: S). Term s (PPosixTime :--> PPosixTime))
-> Term s (PPosixTime :--> PPosixTime)
forall (a :: PType) (s :: S).
HasCallStack =>
ClosedTerm a -> Term s a
phoistAcyclic ((forall (s :: S). Term s (PPosixTime :--> PPosixTime))
 -> Term s (PPosixTime :--> PPosixTime))
-> (forall (s :: S). Term s (PPosixTime :--> PPosixTime))
-> Term s (PPosixTime :--> PPosixTime)
forall a b. (a -> b) -> a -> b
$ (Term s PPosixTime -> Term s PPosixTime)
-> Term s (PPosixTime :--> PPosixTime)
forall a (b :: PType) (s :: S) (c :: PType).
(PLamN a b s, HasCallStack) =>
(Term s c -> a) -> Term s (c :--> b)
forall (c :: PType).
HasCallStack =>
(Term s c -> Term s PPosixTime) -> Term s (c :--> PPosixTime)
plam (Term s PPosixTime -> Term s PPosixTime -> Term s PPosixTime
forall a. Num a => a -> a -> a
+ Term s PPosixTime
1)
  {-# INLINEABLE psuccessorN #-}
  psuccessorN :: forall (s :: S).
Term s (PPositive :--> (PPosixTime :--> PPosixTime))
psuccessorN = (forall (s :: S).
 Term s (PPositive :--> (PPosixTime :--> PPosixTime)))
-> Term s (PPositive :--> (PPosixTime :--> PPosixTime))
forall (a :: PType) (s :: S).
HasCallStack =>
ClosedTerm a -> Term s a
phoistAcyclic ((forall (s :: S).
  Term s (PPositive :--> (PPosixTime :--> PPosixTime)))
 -> Term s (PPositive :--> (PPosixTime :--> PPosixTime)))
-> (forall (s :: S).
    Term s (PPositive :--> (PPosixTime :--> PPosixTime)))
-> Term s (PPositive :--> (PPosixTime :--> PPosixTime))
forall a b. (a -> b) -> a -> b
$ (Term s PPositive -> Term s PPosixTime -> Term s PPosixTime)
-> Term s (PPositive :--> (PPosixTime :--> PPosixTime))
forall a (b :: PType) (s :: S) (c :: PType).
(PLamN a b s, HasCallStack) =>
(Term s c -> a) -> Term s (c :--> b)
forall (c :: PType).
HasCallStack =>
(Term s c -> Term s PPosixTime -> Term s PPosixTime)
-> Term s (c :--> (PPosixTime :--> PPosixTime))
plam ((Term s PPositive -> Term s PPosixTime -> Term s PPosixTime)
 -> Term s (PPositive :--> (PPosixTime :--> PPosixTime)))
-> (Term s PPositive -> Term s PPosixTime -> Term s PPosixTime)
-> Term s (PPositive :--> (PPosixTime :--> PPosixTime))
forall a b. (a -> b) -> a -> b
$ \Term s PPositive
p Term s PPosixTime
t ->
    let p' :: Term s PPosixTime
p' = PPosixTime s -> Term s PPosixTime
forall (a :: PType) (s :: S). PlutusType a => a s -> Term s a
pcon (PPosixTime s -> Term s PPosixTime)
-> (Term s PPositive -> PPosixTime s)
-> Term s PPositive
-> Term s PPosixTime
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Term s (PDataNewtype PInteger) -> PPosixTime s
forall (s :: S). Term s (PDataNewtype PInteger) -> PPosixTime s
PPosixTime (Term s (PDataNewtype PInteger) -> PPosixTime s)
-> (Term s PPositive -> Term s (PDataNewtype PInteger))
-> Term s PPositive
-> PPosixTime s
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PDataNewtype PInteger s -> Term s (PDataNewtype PInteger)
forall (a :: PType) (s :: S). PlutusType a => a s -> Term s a
pcon (PDataNewtype PInteger s -> Term s (PDataNewtype PInteger))
-> (Term s PPositive -> PDataNewtype PInteger s)
-> Term s PPositive
-> Term s (PDataNewtype PInteger)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Term s (PAsData PInteger) -> PDataNewtype PInteger s
forall (a :: PType) (s :: S).
Term s (PAsData a) -> PDataNewtype a s
PDataNewtype (Term s (PAsData PInteger) -> PDataNewtype PInteger s)
-> (Term s PPositive -> Term s (PAsData PInteger))
-> Term s PPositive
-> PDataNewtype PInteger s
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Term s PInteger -> Term s (PAsData PInteger)
forall (a :: PType) (s :: S).
PIsData a =>
Term s a -> Term s (PAsData a)
pdata (Term s PInteger -> Term s (PAsData PInteger))
-> (Term s PPositive -> Term s PInteger)
-> Term s PPositive
-> Term s (PAsData PInteger)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Term s PPositive -> Term s PInteger
Term s PPositive -> Term s (PInner PPositive)
forall (s :: S) (a :: PType). Term s a -> Term s (PInner a)
pto (Term s PPositive -> Term s PPosixTime)
-> Term s PPositive -> Term s PPosixTime
forall a b. (a -> b) -> a -> b
$ Term s PPositive
p
     in Term s PPosixTime
p' Term s PPosixTime -> Term s PPosixTime -> Term s PPosixTime
forall a. Num a => a -> a -> a
+ Term s PPosixTime
t

-- | @since WIP
instance PEnumerable PPosixTime where
  {-# INLINEABLE ppredecessor #-}
  ppredecessor :: forall (s :: S). Term s (PPosixTime :--> PPosixTime)
ppredecessor = (forall (s :: S). Term s (PPosixTime :--> PPosixTime))
-> Term s (PPosixTime :--> PPosixTime)
forall (a :: PType) (s :: S).
HasCallStack =>
ClosedTerm a -> Term s a
phoistAcyclic ((forall (s :: S). Term s (PPosixTime :--> PPosixTime))
 -> Term s (PPosixTime :--> PPosixTime))
-> (forall (s :: S). Term s (PPosixTime :--> PPosixTime))
-> Term s (PPosixTime :--> PPosixTime)
forall a b. (a -> b) -> a -> b
$ (Term s PPosixTime -> Term s PPosixTime)
-> Term s (PPosixTime :--> PPosixTime)
forall a (b :: PType) (s :: S) (c :: PType).
(PLamN a b s, HasCallStack) =>
(Term s c -> a) -> Term s (c :--> b)
forall (c :: PType).
HasCallStack =>
(Term s c -> Term s PPosixTime) -> Term s (c :--> PPosixTime)
plam (\Term s PPosixTime
t -> Term s PPosixTime
t Term s PPosixTime -> Term s PPosixTime -> Term s PPosixTime
forall a. Num a => a -> a -> a
- Term s PPosixTime
1)
  {-# INLINEABLE ppredecessorN #-}
  ppredecessorN :: forall (s :: S).
Term s (PPositive :--> (PPosixTime :--> PPosixTime))
ppredecessorN = (forall (s :: S).
 Term s (PPositive :--> (PPosixTime :--> PPosixTime)))
-> Term s (PPositive :--> (PPosixTime :--> PPosixTime))
forall (a :: PType) (s :: S).
HasCallStack =>
ClosedTerm a -> Term s a
phoistAcyclic ((forall (s :: S).
  Term s (PPositive :--> (PPosixTime :--> PPosixTime)))
 -> Term s (PPositive :--> (PPosixTime :--> PPosixTime)))
-> (forall (s :: S).
    Term s (PPositive :--> (PPosixTime :--> PPosixTime)))
-> Term s (PPositive :--> (PPosixTime :--> PPosixTime))
forall a b. (a -> b) -> a -> b
$ (Term s PPositive -> Term s PPosixTime -> Term s PPosixTime)
-> Term s (PPositive :--> (PPosixTime :--> PPosixTime))
forall a (b :: PType) (s :: S) (c :: PType).
(PLamN a b s, HasCallStack) =>
(Term s c -> a) -> Term s (c :--> b)
forall (c :: PType).
HasCallStack =>
(Term s c -> Term s PPosixTime -> Term s PPosixTime)
-> Term s (c :--> (PPosixTime :--> PPosixTime))
plam ((Term s PPositive -> Term s PPosixTime -> Term s PPosixTime)
 -> Term s (PPositive :--> (PPosixTime :--> PPosixTime)))
-> (Term s PPositive -> Term s PPosixTime -> Term s PPosixTime)
-> Term s (PPositive :--> (PPosixTime :--> PPosixTime))
forall a b. (a -> b) -> a -> b
$ \Term s PPositive
p Term s PPosixTime
t ->
    let p' :: Term s PPosixTime
p' = PPosixTime s -> Term s PPosixTime
forall (a :: PType) (s :: S). PlutusType a => a s -> Term s a
pcon (PPosixTime s -> Term s PPosixTime)
-> (Term s PPositive -> PPosixTime s)
-> Term s PPositive
-> Term s PPosixTime
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Term s (PDataNewtype PInteger) -> PPosixTime s
forall (s :: S). Term s (PDataNewtype PInteger) -> PPosixTime s
PPosixTime (Term s (PDataNewtype PInteger) -> PPosixTime s)
-> (Term s PPositive -> Term s (PDataNewtype PInteger))
-> Term s PPositive
-> PPosixTime s
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PDataNewtype PInteger s -> Term s (PDataNewtype PInteger)
forall (a :: PType) (s :: S). PlutusType a => a s -> Term s a
pcon (PDataNewtype PInteger s -> Term s (PDataNewtype PInteger))
-> (Term s PPositive -> PDataNewtype PInteger s)
-> Term s PPositive
-> Term s (PDataNewtype PInteger)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Term s (PAsData PInteger) -> PDataNewtype PInteger s
forall (a :: PType) (s :: S).
Term s (PAsData a) -> PDataNewtype a s
PDataNewtype (Term s (PAsData PInteger) -> PDataNewtype PInteger s)
-> (Term s PPositive -> Term s (PAsData PInteger))
-> Term s PPositive
-> PDataNewtype PInteger s
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Term s PInteger -> Term s (PAsData PInteger)
forall (a :: PType) (s :: S).
PIsData a =>
Term s a -> Term s (PAsData a)
pdata (Term s PInteger -> Term s (PAsData PInteger))
-> (Term s PPositive -> Term s PInteger)
-> Term s PPositive
-> Term s (PAsData PInteger)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Term s PPositive -> Term s PInteger
Term s PPositive -> Term s (PInner PPositive)
forall (s :: S) (a :: PType). Term s a -> Term s (PInner a)
pto (Term s PPositive -> Term s PPosixTime)
-> Term s PPositive -> Term s PPosixTime
forall a b. (a -> b) -> a -> b
$ Term s PPositive
p
     in Term s PPosixTime
t Term s PPosixTime -> Term s PPosixTime -> Term s PPosixTime
forall a. Num a => a -> a -> a
- Term s PPosixTime
p'

-- | @since 2.0.0
instance PIntegral PPosixTime where
  {-# INLINEABLE pdiv #-}
  pdiv :: forall (s :: S).
Term s (PPosixTime :--> (PPosixTime :--> PPosixTime))
pdiv = (forall (s :: S).
 Term s (PPosixTime :--> (PPosixTime :--> PPosixTime)))
-> Term s (PPosixTime :--> (PPosixTime :--> PPosixTime))
forall (a :: PType) (s :: S).
HasCallStack =>
ClosedTerm a -> Term s a
phoistAcyclic ((forall (s :: S).
  Term s (PPosixTime :--> (PPosixTime :--> PPosixTime)))
 -> Term s (PPosixTime :--> (PPosixTime :--> PPosixTime)))
-> (forall (s :: S).
    Term s (PPosixTime :--> (PPosixTime :--> PPosixTime)))
-> Term s (PPosixTime :--> (PPosixTime :--> PPosixTime))
forall a b. (a -> b) -> a -> b
$ (Term s PPosixTime -> Term s PPosixTime -> Term s PPosixTime)
-> Term s (PPosixTime :--> (PPosixTime :--> PPosixTime))
forall a (b :: PType) (s :: S) (c :: PType).
(PLamN a b s, HasCallStack) =>
(Term s c -> a) -> Term s (c :--> b)
forall (c :: PType).
HasCallStack =>
(Term s c -> Term s PPosixTime -> Term s PPosixTime)
-> Term s (c :--> (PPosixTime :--> PPosixTime))
plam ((Term s PPosixTime -> Term s PPosixTime -> Term s PPosixTime)
 -> Term s (PPosixTime :--> (PPosixTime :--> PPosixTime)))
-> (Term s PPosixTime -> Term s PPosixTime -> Term s PPosixTime)
-> Term s (PPosixTime :--> (PPosixTime :--> PPosixTime))
forall a b. (a -> b) -> a -> b
$ \Term s PPosixTime
t1 Term s PPosixTime
t2 ->
    Term s PInteger -> Term s PPosixTime
forall (s :: S). Term s PInteger -> Term s PPosixTime
pposixTime (Term s (PInteger :--> (PInteger :--> PInteger))
forall (s :: S). Term s (PInteger :--> (PInteger :--> PInteger))
forall (a :: PType) (s :: S).
PIntegral a =>
Term s (a :--> (a :--> a))
pdiv Term s (PInteger :--> (PInteger :--> PInteger))
-> Term s PInteger -> Term s (PInteger :--> PInteger)
forall (s :: S) (a :: PType) (b :: PType).
Term s (a :--> b) -> Term s a -> Term s b
# Term s PPosixTime -> Term s PInteger
forall (s :: S). Term s PPosixTime -> Term s PInteger
unPPosixTime Term s PPosixTime
t1 Term s (PInteger :--> PInteger)
-> Term s PInteger -> Term s PInteger
forall (s :: S) (a :: PType) (b :: PType).
Term s (a :--> b) -> Term s a -> Term s b
# Term s PPosixTime -> Term s PInteger
forall (s :: S). Term s PPosixTime -> Term s PInteger
unPPosixTime Term s PPosixTime
t2)
  {-# INLINEABLE pmod #-}
  pmod :: forall (s :: S).
Term s (PPosixTime :--> (PPosixTime :--> PPosixTime))
pmod = (forall (s :: S).
 Term s (PPosixTime :--> (PPosixTime :--> PPosixTime)))
-> Term s (PPosixTime :--> (PPosixTime :--> PPosixTime))
forall (a :: PType) (s :: S).
HasCallStack =>
ClosedTerm a -> Term s a
phoistAcyclic ((forall (s :: S).
  Term s (PPosixTime :--> (PPosixTime :--> PPosixTime)))
 -> Term s (PPosixTime :--> (PPosixTime :--> PPosixTime)))
-> (forall (s :: S).
    Term s (PPosixTime :--> (PPosixTime :--> PPosixTime)))
-> Term s (PPosixTime :--> (PPosixTime :--> PPosixTime))
forall a b. (a -> b) -> a -> b
$ (Term s PPosixTime -> Term s PPosixTime -> Term s PPosixTime)
-> Term s (PPosixTime :--> (PPosixTime :--> PPosixTime))
forall a (b :: PType) (s :: S) (c :: PType).
(PLamN a b s, HasCallStack) =>
(Term s c -> a) -> Term s (c :--> b)
forall (c :: PType).
HasCallStack =>
(Term s c -> Term s PPosixTime -> Term s PPosixTime)
-> Term s (c :--> (PPosixTime :--> PPosixTime))
plam ((Term s PPosixTime -> Term s PPosixTime -> Term s PPosixTime)
 -> Term s (PPosixTime :--> (PPosixTime :--> PPosixTime)))
-> (Term s PPosixTime -> Term s PPosixTime -> Term s PPosixTime)
-> Term s (PPosixTime :--> (PPosixTime :--> PPosixTime))
forall a b. (a -> b) -> a -> b
$ \Term s PPosixTime
t1 Term s PPosixTime
t2 ->
    Term s PInteger -> Term s PPosixTime
forall (s :: S). Term s PInteger -> Term s PPosixTime
pposixTime (Term s (PInteger :--> (PInteger :--> PInteger))
forall (s :: S). Term s (PInteger :--> (PInteger :--> PInteger))
forall (a :: PType) (s :: S).
PIntegral a =>
Term s (a :--> (a :--> a))
pmod Term s (PInteger :--> (PInteger :--> PInteger))
-> Term s PInteger -> Term s (PInteger :--> PInteger)
forall (s :: S) (a :: PType) (b :: PType).
Term s (a :--> b) -> Term s a -> Term s b
# Term s PPosixTime -> Term s PInteger
forall (s :: S). Term s PPosixTime -> Term s PInteger
unPPosixTime Term s PPosixTime
t1 Term s (PInteger :--> PInteger)
-> Term s PInteger -> Term s PInteger
forall (s :: S) (a :: PType) (b :: PType).
Term s (a :--> b) -> Term s a -> Term s b
# Term s PPosixTime -> Term s PInteger
forall (s :: S). Term s PPosixTime -> Term s PInteger
unPPosixTime Term s PPosixTime
t2)
  {-# INLINEABLE pquot #-}
  pquot :: forall (s :: S).
Term s (PPosixTime :--> (PPosixTime :--> PPosixTime))
pquot = (forall (s :: S).
 Term s (PPosixTime :--> (PPosixTime :--> PPosixTime)))
-> Term s (PPosixTime :--> (PPosixTime :--> PPosixTime))
forall (a :: PType) (s :: S).
HasCallStack =>
ClosedTerm a -> Term s a
phoistAcyclic ((forall (s :: S).
  Term s (PPosixTime :--> (PPosixTime :--> PPosixTime)))
 -> Term s (PPosixTime :--> (PPosixTime :--> PPosixTime)))
-> (forall (s :: S).
    Term s (PPosixTime :--> (PPosixTime :--> PPosixTime)))
-> Term s (PPosixTime :--> (PPosixTime :--> PPosixTime))
forall a b. (a -> b) -> a -> b
$ (Term s PPosixTime -> Term s PPosixTime -> Term s PPosixTime)
-> Term s (PPosixTime :--> (PPosixTime :--> PPosixTime))
forall a (b :: PType) (s :: S) (c :: PType).
(PLamN a b s, HasCallStack) =>
(Term s c -> a) -> Term s (c :--> b)
forall (c :: PType).
HasCallStack =>
(Term s c -> Term s PPosixTime -> Term s PPosixTime)
-> Term s (c :--> (PPosixTime :--> PPosixTime))
plam ((Term s PPosixTime -> Term s PPosixTime -> Term s PPosixTime)
 -> Term s (PPosixTime :--> (PPosixTime :--> PPosixTime)))
-> (Term s PPosixTime -> Term s PPosixTime -> Term s PPosixTime)
-> Term s (PPosixTime :--> (PPosixTime :--> PPosixTime))
forall a b. (a -> b) -> a -> b
$ \Term s PPosixTime
t1 Term s PPosixTime
t2 ->
    Term s PInteger -> Term s PPosixTime
forall (s :: S). Term s PInteger -> Term s PPosixTime
pposixTime (Term s (PInteger :--> (PInteger :--> PInteger))
forall (s :: S). Term s (PInteger :--> (PInteger :--> PInteger))
forall (a :: PType) (s :: S).
PIntegral a =>
Term s (a :--> (a :--> a))
pquot Term s (PInteger :--> (PInteger :--> PInteger))
-> Term s PInteger -> Term s (PInteger :--> PInteger)
forall (s :: S) (a :: PType) (b :: PType).
Term s (a :--> b) -> Term s a -> Term s b
# Term s PPosixTime -> Term s PInteger
forall (s :: S). Term s PPosixTime -> Term s PInteger
unPPosixTime Term s PPosixTime
t1 Term s (PInteger :--> PInteger)
-> Term s PInteger -> Term s PInteger
forall (s :: S) (a :: PType) (b :: PType).
Term s (a :--> b) -> Term s a -> Term s b
# Term s PPosixTime -> Term s PInteger
forall (s :: S). Term s PPosixTime -> Term s PInteger
unPPosixTime Term s PPosixTime
t2)
  {-# INLINEABLE prem #-}
  prem :: forall (s :: S).
Term s (PPosixTime :--> (PPosixTime :--> PPosixTime))
prem = (forall (s :: S).
 Term s (PPosixTime :--> (PPosixTime :--> PPosixTime)))
-> Term s (PPosixTime :--> (PPosixTime :--> PPosixTime))
forall (a :: PType) (s :: S).
HasCallStack =>
ClosedTerm a -> Term s a
phoistAcyclic ((forall (s :: S).
  Term s (PPosixTime :--> (PPosixTime :--> PPosixTime)))
 -> Term s (PPosixTime :--> (PPosixTime :--> PPosixTime)))
-> (forall (s :: S).
    Term s (PPosixTime :--> (PPosixTime :--> PPosixTime)))
-> Term s (PPosixTime :--> (PPosixTime :--> PPosixTime))
forall a b. (a -> b) -> a -> b
$ (Term s PPosixTime -> Term s PPosixTime -> Term s PPosixTime)
-> Term s (PPosixTime :--> (PPosixTime :--> PPosixTime))
forall a (b :: PType) (s :: S) (c :: PType).
(PLamN a b s, HasCallStack) =>
(Term s c -> a) -> Term s (c :--> b)
forall (c :: PType).
HasCallStack =>
(Term s c -> Term s PPosixTime -> Term s PPosixTime)
-> Term s (c :--> (PPosixTime :--> PPosixTime))
plam ((Term s PPosixTime -> Term s PPosixTime -> Term s PPosixTime)
 -> Term s (PPosixTime :--> (PPosixTime :--> PPosixTime)))
-> (Term s PPosixTime -> Term s PPosixTime -> Term s PPosixTime)
-> Term s (PPosixTime :--> (PPosixTime :--> PPosixTime))
forall a b. (a -> b) -> a -> b
$ \Term s PPosixTime
t1 Term s PPosixTime
t2 ->
    Term s PInteger -> Term s PPosixTime
forall (s :: S). Term s PInteger -> Term s PPosixTime
pposixTime (Term s (PInteger :--> (PInteger :--> PInteger))
forall (s :: S). Term s (PInteger :--> (PInteger :--> PInteger))
forall (a :: PType) (s :: S).
PIntegral a =>
Term s (a :--> (a :--> a))
prem Term s (PInteger :--> (PInteger :--> PInteger))
-> Term s PInteger -> Term s (PInteger :--> PInteger)
forall (s :: S) (a :: PType) (b :: PType).
Term s (a :--> b) -> Term s a -> Term s b
# Term s PPosixTime -> Term s PInteger
forall (s :: S). Term s PPosixTime -> Term s PInteger
unPPosixTime Term s PPosixTime
t1 Term s (PInteger :--> PInteger)
-> Term s PInteger -> Term s PInteger
forall (s :: S) (a :: PType) (b :: PType).
Term s (a :--> b) -> Term s a -> Term s b
# Term s PPosixTime -> Term s PInteger
forall (s :: S). Term s PPosixTime -> Term s PInteger
unPPosixTime Term s PPosixTime
t2)

-- | @since 2.0.0
instance PNum PPosixTime where
  {-# INLINEABLE (#*) #-}
  Term s PPosixTime
t1 #* :: forall (s :: S).
Term s PPosixTime -> Term s PPosixTime -> Term s PPosixTime
#* Term s PPosixTime
t2 = Term s PInteger -> Term s PPosixTime
forall (s :: S). Term s PInteger -> Term s PPosixTime
pposixTime (Term s PPosixTime -> Term s PInteger
forall (s :: S). Term s PPosixTime -> Term s PInteger
unPPosixTime Term s PPosixTime
t1 Term s PInteger -> Term s PInteger -> Term s PInteger
forall (s :: S).
Term s PInteger -> Term s PInteger -> Term s PInteger
forall (a :: PType) (s :: S).
PNum a =>
Term s a -> Term s a -> Term s a
#* Term s PPosixTime -> Term s PInteger
forall (s :: S). Term s PPosixTime -> Term s PInteger
unPPosixTime Term s PPosixTime
t2)
  {-# INLINEABLE (#+) #-}
  Term s PPosixTime
t1 #+ :: forall (s :: S).
Term s PPosixTime -> Term s PPosixTime -> Term s PPosixTime
#+ Term s PPosixTime
t2 = Term s PInteger -> Term s PPosixTime
forall (s :: S). Term s PInteger -> Term s PPosixTime
pposixTime (Term s PPosixTime -> Term s PInteger
forall (s :: S). Term s PPosixTime -> Term s PInteger
unPPosixTime Term s PPosixTime
t1 Term s PInteger -> Term s PInteger -> Term s PInteger
forall (s :: S).
Term s PInteger -> Term s PInteger -> Term s PInteger
forall (a :: PType) (s :: S).
PNum a =>
Term s a -> Term s a -> Term s a
#+ Term s PPosixTime -> Term s PInteger
forall (s :: S). Term s PPosixTime -> Term s PInteger
unPPosixTime Term s PPosixTime
t2)
  {-# INLINEABLE (#-) #-}
  Term s PPosixTime
t1 #- :: forall (s :: S).
Term s PPosixTime -> Term s PPosixTime -> Term s PPosixTime
#- Term s PPosixTime
t2 = Term s PInteger -> Term s PPosixTime
forall (s :: S). Term s PInteger -> Term s PPosixTime
pposixTime (Term s PPosixTime -> Term s PInteger
forall (s :: S). Term s PPosixTime -> Term s PInteger
unPPosixTime Term s PPosixTime
t1 Term s PInteger -> Term s PInteger -> Term s PInteger
forall (s :: S).
Term s PInteger -> Term s PInteger -> Term s PInteger
forall (a :: PType) (s :: S).
PNum a =>
Term s a -> Term s a -> Term s a
#- Term s PPosixTime -> Term s PInteger
forall (s :: S). Term s PPosixTime -> Term s PInteger
unPPosixTime Term s PPosixTime
t2)
  {-# INLINEABLE pabs #-}
  pabs :: forall (s :: S). Term s (PPosixTime :--> PPosixTime)
pabs = (forall (s :: S). Term s (PPosixTime :--> PPosixTime))
-> Term s (PPosixTime :--> PPosixTime)
forall (a :: PType) (s :: S).
HasCallStack =>
ClosedTerm a -> Term s a
phoistAcyclic ((forall (s :: S). Term s (PPosixTime :--> PPosixTime))
 -> Term s (PPosixTime :--> PPosixTime))
-> (forall (s :: S). Term s (PPosixTime :--> PPosixTime))
-> Term s (PPosixTime :--> PPosixTime)
forall a b. (a -> b) -> a -> b
$ (Term s PPosixTime -> Term s PPosixTime)
-> Term s (PPosixTime :--> PPosixTime)
forall a (b :: PType) (s :: S) (c :: PType).
(PLamN a b s, HasCallStack) =>
(Term s c -> a) -> Term s (c :--> b)
forall (c :: PType).
HasCallStack =>
(Term s c -> Term s PPosixTime) -> Term s (c :--> PPosixTime)
plam ((Term s PPosixTime -> Term s PPosixTime)
 -> Term s (PPosixTime :--> PPosixTime))
-> (Term s PPosixTime -> Term s PPosixTime)
-> Term s (PPosixTime :--> PPosixTime)
forall a b. (a -> b) -> a -> b
$ \Term s PPosixTime
t -> Term s PInteger -> Term s PPosixTime
forall (s :: S). Term s PInteger -> Term s PPosixTime
pposixTime (Term s (PInteger :--> PInteger)
forall (s :: S). Term s (PInteger :--> PInteger)
forall (a :: PType) (s :: S). PNum a => Term s (a :--> a)
pabs Term s (PInteger :--> PInteger)
-> Term s PInteger -> Term s PInteger
forall (s :: S) (a :: PType) (b :: PType).
Term s (a :--> b) -> Term s a -> Term s b
# Term s PPosixTime -> Term s PInteger
forall (s :: S). Term s PPosixTime -> Term s PInteger
unPPosixTime Term s PPosixTime
t)
  {-# INLINEABLE pfromInteger #-}
  pfromInteger :: forall (s :: S). Integer -> Term s PPosixTime
pfromInteger = Term s PInteger -> Term s PPosixTime
forall (s :: S). Term s PInteger -> Term s PPosixTime
pposixTime (Term s PInteger -> Term s PPosixTime)
-> (Integer -> Term s PInteger) -> Integer -> Term s PPosixTime
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Integer -> Term s PInteger
AsHaskell PInteger -> Term s PInteger
forall (a :: PType) (s :: S).
PLiftable a =>
AsHaskell a -> Term s a
pconstant
  {-# INLINEABLE pnegate #-}
  pnegate :: forall (s :: S). Term s (PPosixTime :--> PPosixTime)
pnegate = (forall (s :: S). Term s (PPosixTime :--> PPosixTime))
-> Term s (PPosixTime :--> PPosixTime)
forall (a :: PType) (s :: S).
HasCallStack =>
ClosedTerm a -> Term s a
phoistAcyclic ((forall (s :: S). Term s (PPosixTime :--> PPosixTime))
 -> Term s (PPosixTime :--> PPosixTime))
-> (forall (s :: S). Term s (PPosixTime :--> PPosixTime))
-> Term s (PPosixTime :--> PPosixTime)
forall a b. (a -> b) -> a -> b
$ (Term s PPosixTime -> Term s PPosixTime)
-> Term s (PPosixTime :--> PPosixTime)
forall a (b :: PType) (s :: S) (c :: PType).
(PLamN a b s, HasCallStack) =>
(Term s c -> a) -> Term s (c :--> b)
forall (c :: PType).
HasCallStack =>
(Term s c -> Term s PPosixTime) -> Term s (c :--> PPosixTime)
plam ((Term s PPosixTime -> Term s PPosixTime)
 -> Term s (PPosixTime :--> PPosixTime))
-> (Term s PPosixTime -> Term s PPosixTime)
-> Term s (PPosixTime :--> PPosixTime)
forall a b. (a -> b) -> a -> b
$ \Term s PPosixTime
t -> Term s PInteger -> Term s PPosixTime
forall (s :: S). Term s PInteger -> Term s PPosixTime
pposixTime (Term s (PInteger :--> PInteger)
forall (s :: S). Term s (PInteger :--> PInteger)
forall (a :: PType) (s :: S). PNum a => Term s (a :--> a)
pnegate Term s (PInteger :--> PInteger)
-> Term s PInteger -> Term s PInteger
forall (s :: S) (a :: PType) (b :: PType).
Term s (a :--> b) -> Term s a -> Term s b
# Term s PPosixTime -> Term s PInteger
forall (s :: S). Term s PPosixTime -> Term s PInteger
unPPosixTime Term s PPosixTime
t)
  {-# INLINEABLE psignum #-}
  psignum :: forall (s :: S). Term s (PPosixTime :--> PPosixTime)
psignum = (forall (s :: S). Term s (PPosixTime :--> PPosixTime))
-> Term s (PPosixTime :--> PPosixTime)
forall (a :: PType) (s :: S).
HasCallStack =>
ClosedTerm a -> Term s a
phoistAcyclic ((forall (s :: S). Term s (PPosixTime :--> PPosixTime))
 -> Term s (PPosixTime :--> PPosixTime))
-> (forall (s :: S). Term s (PPosixTime :--> PPosixTime))
-> Term s (PPosixTime :--> PPosixTime)
forall a b. (a -> b) -> a -> b
$ (Term s PPosixTime -> Term s PPosixTime)
-> Term s (PPosixTime :--> PPosixTime)
forall a (b :: PType) (s :: S) (c :: PType).
(PLamN a b s, HasCallStack) =>
(Term s c -> a) -> Term s (c :--> b)
forall (c :: PType).
HasCallStack =>
(Term s c -> Term s PPosixTime) -> Term s (c :--> PPosixTime)
plam ((Term s PPosixTime -> Term s PPosixTime)
 -> Term s (PPosixTime :--> PPosixTime))
-> (Term s PPosixTime -> Term s PPosixTime)
-> Term s (PPosixTime :--> PPosixTime)
forall a b. (a -> b) -> a -> b
$ \Term s PPosixTime
t -> Term s PInteger -> Term s PPosixTime
forall (s :: S). Term s PInteger -> Term s PPosixTime
pposixTime (Term s (PInteger :--> PInteger)
forall (s :: S). Term s (PInteger :--> PInteger)
forall (a :: PType) (s :: S). PNum a => Term s (a :--> a)
psignum Term s (PInteger :--> PInteger)
-> Term s PInteger -> Term s PInteger
forall (s :: S) (a :: PType) (b :: PType).
Term s (a :--> b) -> Term s a -> Term s b
# Term s PPosixTime -> Term s PInteger
forall (s :: S). Term s PPosixTime -> Term s PInteger
unPPosixTime Term s PPosixTime
t)

-- | @since 2.0.0
instance DerivePlutusType PPosixTime where
  type DPTStrat _ = PlutusTypeNewtype

-- | @since WIP
deriving via
  DeriveDataPLiftable PPosixTime Plutus.POSIXTime
  instance
    PLiftable PPosixTime

-- | @since 3.1.0
instance PTryFrom PData PPosixTime where
  type PTryFromExcess PData PPosixTime = Mret PPosixTime
  ptryFrom' ::
    forall (s :: S) (r :: S -> Type).
    Term s PData ->
    ((Term s PPosixTime, Reduce (PTryFromExcess PData PPosixTime s)) -> Term s r) ->
    Term s r
  ptryFrom' :: forall (s :: S) (r :: PType).
Term s PData
-> ((Term s PPosixTime, Reduce (PTryFromExcess PData PPosixTime s))
    -> Term s r)
-> Term s r
ptryFrom' Term s PData
opq = TermCont
  s (Term s PPosixTime, Reduce (PTryFromExcess PData PPosixTime s))
-> ((Term s PPosixTime, Reduce (PTryFromExcess PData PPosixTime s))
    -> Term s r)
-> Term s r
forall (r :: PType) (s :: S) a.
TermCont s a -> (a -> Term s r) -> Term s r
runTermCont (TermCont
   s (Term s PPosixTime, Reduce (PTryFromExcess PData PPosixTime s))
 -> ((Term s PPosixTime, Reduce (PTryFromExcess PData PPosixTime s))
     -> Term s r)
 -> Term s r)
-> TermCont
     s (Term s PPosixTime, Reduce (PTryFromExcess PData PPosixTime s))
-> ((Term s PPosixTime, Reduce (PTryFromExcess PData PPosixTime s))
    -> Term s r)
-> Term s r
forall a b. (a -> b) -> a -> b
$ do
    (Term s (PAsData PInteger)
wrapped :: Term s (PAsData PInteger), Term s PInteger
unwrapped :: Term s PInteger) <-
      (((Term s (PAsData PInteger), Term s PInteger) -> Term s r)
 -> Term s r)
-> TermCont s (Term s (PAsData PInteger), Term s PInteger)
forall a (s :: S) (r :: PType).
((a -> Term s r) -> Term s r) -> TermCont s a
tcont ((((Term s (PAsData PInteger), Term s PInteger) -> Term s r)
  -> Term s r)
 -> TermCont s (Term s (PAsData PInteger), Term s PInteger))
-> (((Term s (PAsData PInteger), Term s PInteger) -> Term s r)
    -> Term s r)
-> TermCont s (Term s (PAsData PInteger), Term s PInteger)
forall a b. (a -> b) -> a -> b
$ forall (b :: PType) (a :: PType) (s :: S) (r :: PType).
PTryFrom a b =>
Term s a
-> ((Term s b, Reduce (PTryFromExcess a b s)) -> Term s r)
-> Term s r
ptryFrom @(PAsData PInteger) Term s PData
opq
    (Term s PPosixTime, Term s PPosixTime)
-> TermCont s (Term s PPosixTime, Term s PPosixTime)
forall a. a -> TermCont s a
forall (f :: Type -> Type) a. Applicative f => a -> f a
pure (Term s (PAsData PInteger) -> Term s PPosixTime
forall (s :: S) (a :: PType) (b :: PType). Term s a -> Term s b
punsafeCoerce Term s (PAsData PInteger)
wrapped, Term s PInteger -> Term s PPosixTime
forall (s :: S). Term s PInteger -> Term s PPosixTime
pposixTime Term s PInteger
unwrapped)

-- | @since 2.0.0
instance PTryFrom PData (PAsData PPosixTime) where
  type PTryFromExcess PData (PAsData PPosixTime) = Mret PPosixTime
  ptryFrom' ::
    forall (s :: S) (r :: S -> Type).
    Term s PData ->
    ((Term s (PAsData PPosixTime), Reduce (PTryFromExcess PData (PAsData PPosixTime) s)) -> Term s r) ->
    Term s r
  ptryFrom' :: forall (s :: S) (r :: PType).
Term s PData
-> ((Term s (PAsData PPosixTime),
     Reduce (PTryFromExcess PData (PAsData PPosixTime) s))
    -> Term s r)
-> Term s r
ptryFrom' Term s PData
opq = TermCont
  s
  (Term s (PAsData PPosixTime),
   Reduce (PTryFromExcess PData (PAsData PPosixTime) s))
-> ((Term s (PAsData PPosixTime),
     Reduce (PTryFromExcess PData (PAsData PPosixTime) s))
    -> Term s r)
-> Term s r
forall (r :: PType) (s :: S) a.
TermCont s a -> (a -> Term s r) -> Term s r
runTermCont (TermCont
   s
   (Term s (PAsData PPosixTime),
    Reduce (PTryFromExcess PData (PAsData PPosixTime) s))
 -> ((Term s (PAsData PPosixTime),
      Reduce (PTryFromExcess PData (PAsData PPosixTime) s))
     -> Term s r)
 -> Term s r)
-> TermCont
     s
     (Term s (PAsData PPosixTime),
      Reduce (PTryFromExcess PData (PAsData PPosixTime) s))
-> ((Term s (PAsData PPosixTime),
     Reduce (PTryFromExcess PData (PAsData PPosixTime) s))
    -> Term s r)
-> Term s r
forall a b. (a -> b) -> a -> b
$ do
    (Term s (PAsData PInteger)
wrapped :: Term s (PAsData PInteger), Term s PInteger
unwrapped :: Term s PInteger) <-
      (((Term s (PAsData PInteger), Term s PInteger) -> Term s r)
 -> Term s r)
-> TermCont s (Term s (PAsData PInteger), Term s PInteger)
forall a (s :: S) (r :: PType).
((a -> Term s r) -> Term s r) -> TermCont s a
tcont ((((Term s (PAsData PInteger), Term s PInteger) -> Term s r)
  -> Term s r)
 -> TermCont s (Term s (PAsData PInteger), Term s PInteger))
-> (((Term s (PAsData PInteger), Term s PInteger) -> Term s r)
    -> Term s r)
-> TermCont s (Term s (PAsData PInteger), Term s PInteger)
forall a b. (a -> b) -> a -> b
$ forall (b :: PType) (a :: PType) (s :: S) (r :: PType).
PTryFrom a b =>
Term s a
-> ((Term s b, Reduce (PTryFromExcess a b s)) -> Term s r)
-> Term s r
ptryFrom @(PAsData PInteger) Term s PData
opq
    (Term s (PAsData PPosixTime), Term s PPosixTime)
-> TermCont s (Term s (PAsData PPosixTime), Term s PPosixTime)
forall a. a -> TermCont s a
forall (f :: Type -> Type) a. Applicative f => a -> f a
pure (Term s (PAsData PInteger) -> Term s (PAsData PPosixTime)
forall (s :: S) (a :: PType) (b :: PType). Term s a -> Term s b
punsafeCoerce Term s (PAsData PInteger)
wrapped, Term s PInteger -> Term s PPosixTime
forall (s :: S). Term s PInteger -> Term s PPosixTime
pposixTime Term s PInteger
unwrapped)

{- | Construct a 'PPosixTime' from a 'PInteger'. Same as using the constructor,
but a lot shorter.

@since WIP
-}
pposixTime :: forall (s :: S). Term s PInteger -> Term s PPosixTime
pposixTime :: forall (s :: S). Term s PInteger -> Term s PPosixTime
pposixTime = PPosixTime s -> Term s PPosixTime
forall (a :: PType) (s :: S). PlutusType a => a s -> Term s a
pcon (PPosixTime s -> Term s PPosixTime)
-> (Term s PInteger -> PPosixTime s)
-> Term s PInteger
-> Term s PPosixTime
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Term s (PDataNewtype PInteger) -> PPosixTime s
forall (s :: S). Term s (PDataNewtype PInteger) -> PPosixTime s
PPosixTime (Term s (PDataNewtype PInteger) -> PPosixTime s)
-> (Term s PInteger -> Term s (PDataNewtype PInteger))
-> Term s PInteger
-> PPosixTime s
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PDataNewtype PInteger s -> Term s (PDataNewtype PInteger)
forall (a :: PType) (s :: S). PlutusType a => a s -> Term s a
pcon (PDataNewtype PInteger s -> Term s (PDataNewtype PInteger))
-> (Term s PInteger -> PDataNewtype PInteger s)
-> Term s PInteger
-> Term s (PDataNewtype PInteger)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Term s (PAsData PInteger) -> PDataNewtype PInteger s
forall (a :: PType) (s :: S).
Term s (PAsData a) -> PDataNewtype a s
PDataNewtype (Term s (PAsData PInteger) -> PDataNewtype PInteger s)
-> (Term s PInteger -> Term s (PAsData PInteger))
-> Term s PInteger
-> PDataNewtype PInteger s
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Term s PInteger -> Term s (PAsData PInteger)
forall (a :: PType) (s :: S).
PIsData a =>
Term s a -> Term s (PAsData a)
pdata

{- | Unwrap a 'PPosixTime' to get a 'PInteger'. Same as using 'pmatch', but a
lot shorter. Also unwraps the @Data@ encoding.

@since WIP
-}
unPPosixTime :: forall (s :: S). Term s PPosixTime -> Term s PInteger
unPPosixTime :: forall (s :: S). Term s PPosixTime -> Term s PInteger
unPPosixTime Term s PPosixTime
t = Term s PPosixTime
-> (PPosixTime s -> Term s PInteger) -> Term s PInteger
forall (a :: PType) (s :: S) (b :: PType).
PlutusType a =>
Term s a -> (a s -> Term s b) -> Term s b
pmatch Term s PPosixTime
t ((PPosixTime s -> Term s PInteger) -> Term s PInteger)
-> (PPosixTime s -> Term s PInteger) -> Term s PInteger
forall a b. (a -> b) -> a -> b
$ \(PPosixTime Term s (PDataNewtype PInteger)
t') ->
  Term s (PDataNewtype PInteger)
-> (PDataNewtype PInteger s -> Term s PInteger) -> Term s PInteger
forall (a :: PType) (s :: S) (b :: PType).
PlutusType a =>
Term s a -> (a s -> Term s b) -> Term s b
pmatch Term s (PDataNewtype PInteger)
t' ((PDataNewtype PInteger s -> Term s PInteger) -> Term s PInteger)
-> (PDataNewtype PInteger s -> Term s PInteger) -> Term s PInteger
forall a b. (a -> b) -> a -> b
$ \(PDataNewtype Term s (PAsData PInteger)
t'') ->
    Term s (PAsData PInteger) -> Term s PInteger
forall (a :: PType) (s :: S).
PIsData a =>
Term s (PAsData a) -> Term s a
pfromData Term s (PAsData PInteger)
t''