{-# OPTIONS_GHC -Wno-deprecations #-}
{-# OPTIONS_GHC -Wno-orphans #-}
module Plutarch.LedgerApi.V4.Time (
PPosixTimeRange (..),
) where
import GHC.Generics (Generic)
import Generics.SOP qualified as SOP
import Plutarch.Internal.Lift (
LiftError (CouldNotDecodeData),
punsafeCoercePLifted,
)
import Plutarch.LedgerApi.Utils (PMaybeData)
import Plutarch.LedgerApi.V1.Time (PPosixTime)
import Plutarch.Prelude
import PlutusLedgerApi.V4 qualified as Plutus
data PPosixTimeRange (s :: S) = PPosixTimeRange
{ forall (s :: S).
PPosixTimeRange s -> Term s (PMaybeData PPosixTime)
pposixTimeRange'fromInclusive :: Term s (PMaybeData PPosixTime)
, forall (s :: S).
PPosixTimeRange s -> Term s (PMaybeData PPosixTime)
pposixTimeRange'untilExclusive :: Term s (PMaybeData PPosixTime)
}
deriving stock
(
(forall x. PPosixTimeRange s -> Rep (PPosixTimeRange s) x)
-> (forall x. Rep (PPosixTimeRange s) x -> PPosixTimeRange s)
-> Generic (PPosixTimeRange s)
forall x. Rep (PPosixTimeRange s) x -> PPosixTimeRange s
forall x. PPosixTimeRange s -> Rep (PPosixTimeRange s) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall (s :: S) x. Rep (PPosixTimeRange s) x -> PPosixTimeRange s
forall (s :: S) x. PPosixTimeRange s -> Rep (PPosixTimeRange s) x
$cfrom :: forall (s :: S) x. PPosixTimeRange s -> Rep (PPosixTimeRange s) x
from :: forall x. PPosixTimeRange s -> Rep (PPosixTimeRange s) x
$cto :: forall (s :: S) x. Rep (PPosixTimeRange s) x -> PPosixTimeRange s
to :: forall x. Rep (PPosixTimeRange s) x -> PPosixTimeRange s
Generic
)
deriving anyclass
(
All SListI (Code (PPosixTimeRange s))
All SListI (Code (PPosixTimeRange s)) =>
(PPosixTimeRange s -> Rep (PPosixTimeRange s))
-> (Rep (PPosixTimeRange s) -> PPosixTimeRange s)
-> Generic (PPosixTimeRange s)
Rep (PPosixTimeRange s) -> PPosixTimeRange s
PPosixTimeRange s -> Rep (PPosixTimeRange s)
forall a.
All SListI (Code a) =>
(a -> Rep a) -> (Rep a -> a) -> Generic a
forall (s :: S). All SListI (Code (PPosixTimeRange s))
forall (s :: S). Rep (PPosixTimeRange s) -> PPosixTimeRange s
forall (s :: S). PPosixTimeRange s -> Rep (PPosixTimeRange s)
$cfrom :: forall (s :: S). PPosixTimeRange s -> Rep (PPosixTimeRange s)
from :: PPosixTimeRange s -> Rep (PPosixTimeRange s)
$cto :: forall (s :: S). Rep (PPosixTimeRange s) -> PPosixTimeRange s
to :: Rep (PPosixTimeRange s) -> PPosixTimeRange s
SOP.Generic
,
(forall (s :: S).
Term s (PAsData PPosixTimeRange) -> Term s PPosixTimeRange)
-> (forall (s :: S). Term s PPosixTimeRange -> Term s PData)
-> PIsData PPosixTimeRange
forall (s :: S).
Term s (PAsData PPosixTimeRange) -> Term s PPosixTimeRange
forall (s :: S). Term s PPosixTimeRange -> Term s PData
forall (a :: S -> Type).
(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 PPosixTimeRange) -> Term s PPosixTimeRange
pfromDataImpl :: forall (s :: S).
Term s (PAsData PPosixTimeRange) -> Term s PPosixTimeRange
$cpdataImpl :: forall (s :: S). Term s PPosixTimeRange -> Term s PData
pdataImpl :: forall (s :: S). Term s PPosixTimeRange -> Term s PData
PIsData
,
(forall (s :: S).
Term s PPosixTimeRange -> Term s PPosixTimeRange -> Term s PBool)
-> PEq PPosixTimeRange
forall (s :: S).
Term s PPosixTimeRange -> Term s PPosixTimeRange -> Term s PBool
forall (t :: S -> Type).
(forall (s :: S). Term s t -> Term s t -> Term s PBool) -> PEq t
$c#== :: forall (s :: S).
Term s PPosixTimeRange -> Term s PPosixTimeRange -> Term s PBool
#== :: forall (s :: S).
Term s PPosixTimeRange -> Term s PPosixTimeRange -> Term s PBool
PEq
,
(forall (s :: S). Bool -> Term s PPosixTimeRange -> Term s PString)
-> PShow PPosixTimeRange
forall (s :: S). Bool -> Term s PPosixTimeRange -> Term s PString
forall (t :: S -> Type).
(forall (s :: S). Bool -> Term s t -> Term s PString) -> PShow t
$cpshow' :: forall (s :: S). Bool -> Term s PPosixTimeRange -> Term s PString
pshow' :: forall (s :: S). Bool -> Term s PPosixTimeRange -> Term s PString
PShow
)
deriving
(
(forall (s :: S).
PPosixTimeRange s -> Term s (PInner PPosixTimeRange))
-> (forall (s :: S) (b :: S -> Type).
Term s (PInner PPosixTimeRange)
-> (PPosixTimeRange s -> Term s b) -> Term s b)
-> PlutusType PPosixTimeRange
forall (s :: S).
PPosixTimeRange s -> Term s (PInner PPosixTimeRange)
forall (s :: S) (b :: S -> Type).
Term s (PInner PPosixTimeRange)
-> (PPosixTimeRange s -> Term s b) -> Term s b
forall (a :: S -> Type).
(forall (s :: S). a s -> Term s (PInner a))
-> (forall (s :: S) (b :: S -> Type).
Term s (PInner a) -> (a s -> Term s b) -> Term s b)
-> PlutusType a
$cpcon' :: forall (s :: S).
PPosixTimeRange s -> Term s (PInner PPosixTimeRange)
pcon' :: forall (s :: S).
PPosixTimeRange s -> Term s (PInner PPosixTimeRange)
$cpmatch' :: forall (s :: S) (b :: S -> Type).
Term s (PInner PPosixTimeRange)
-> (PPosixTimeRange s -> Term s b) -> Term s b
pmatch' :: forall (s :: S) (b :: S -> Type).
Term s (PInner PPosixTimeRange)
-> (PPosixTimeRange s -> Term s b) -> Term s b
PlutusType
,
(forall (s :: S).
Term s PData -> forall (r :: S -> Type). Term s r -> Term s r)
-> PValidateData PPosixTimeRange
forall (s :: S).
Term s PData -> forall (r :: S -> Type). Term s r -> Term s r
forall (a :: S -> Type).
(forall (s :: S).
Term s PData -> forall (r :: S -> Type). Term s r -> Term s r)
-> PValidateData a
$cpwithValidated :: forall (s :: S).
Term s PData -> forall (r :: S -> Type). Term s r -> Term s r
pwithValidated :: forall (s :: S).
Term s PData -> forall (r :: S -> Type). Term s r -> Term s r
PValidateData
)
via (DeriveAsDataRec PPosixTimeRange)
instance PLiftable PPosixTimeRange where
type AsHaskell PPosixTimeRange = Plutus.POSIXTimeRange
type PlutusRepr PPosixTimeRange = Plutus.Data
haskToRepr :: AsHaskell PPosixTimeRange -> PlutusRepr PPosixTimeRange
haskToRepr = AsHaskell PPosixTimeRange -> PlutusRepr PPosixTimeRange
POSIXTimeRange -> Data
forall a. ToData a => a -> Data
Plutus.toData
reprToHask :: PlutusRepr PPosixTimeRange
-> Either LiftError (AsHaskell PPosixTimeRange)
reprToHask = Either LiftError POSIXTimeRange
-> (POSIXTimeRange -> Either LiftError POSIXTimeRange)
-> Maybe POSIXTimeRange
-> Either LiftError POSIXTimeRange
forall b a. b -> (a -> b) -> Maybe a -> b
maybe (LiftError -> Either LiftError POSIXTimeRange
forall a b. a -> Either a b
Left LiftError
CouldNotDecodeData) POSIXTimeRange -> Either LiftError POSIXTimeRange
forall a b. b -> Either a b
Right (Maybe POSIXTimeRange -> Either LiftError POSIXTimeRange)
-> (Data -> Maybe POSIXTimeRange)
-> Data
-> Either LiftError POSIXTimeRange
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Data -> Maybe POSIXTimeRange
forall a. FromData a => Data -> Maybe a
Plutus.fromData
plutToRepr :: (forall (s :: S). PLifted s PPosixTimeRange)
-> Either LiftError (PlutusRepr PPosixTimeRange)
plutToRepr forall (s :: S). PLifted s PPosixTimeRange
t = ([Data] -> PlutusRepr PPosixTimeRange)
-> Either LiftError [Data]
-> Either LiftError (PlutusRepr PPosixTimeRange)
forall a b. (a -> b) -> Either LiftError a -> Either LiftError b
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
fmap [Data] -> PlutusRepr PPosixTimeRange
[Data] -> Data
Plutus.List (Either LiftError [Data]
-> Either LiftError (PlutusRepr PPosixTimeRange))
-> Either LiftError [Data]
-> Either LiftError (PlutusRepr PPosixTimeRange)
forall a b. (a -> b) -> a -> b
$ forall (a :: S -> Type).
KnownBuiltinType
(Term DeBruijn DefaultUni DefaultFun ()) (PlutusRepr a) =>
(forall (s :: S). PLifted s a) -> Either LiftError (PlutusRepr a)
plutToReprUni @(PBuiltinList PData) ((forall (s :: S). PLifted s (PBuiltinList PData))
-> Either LiftError (PlutusRepr (PBuiltinList PData)))
-> (forall (s :: S). PLifted s (PBuiltinList PData))
-> Either LiftError (PlutusRepr (PBuiltinList PData))
forall a b. (a -> b) -> a -> b
$ PLifted s PPosixTimeRange -> PLifted s (PBuiltinList PData)
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
PLifted s a -> PLifted s b
punsafeCoercePLifted PLifted s PPosixTimeRange
forall (s :: S). PLifted s PPosixTimeRange
t
reprToPlut :: forall (s :: S).
PlutusRepr PPosixTimeRange -> PLifted s PPosixTimeRange
reprToPlut = \case
Plutus.List [Data]
ell -> PLifted s (PBuiltinList PData) -> PLifted s PPosixTimeRange
forall (s :: S) (a :: S -> Type) (b :: S -> Type).
PLifted s a -> PLifted s b
punsafeCoercePLifted (forall (a :: S -> Type) (s :: S).
Includes DefaultUni (PlutusRepr a) =>
PlutusRepr a -> PLifted s a
reprToPlutUni @(PBuiltinList PData) [Data]
PlutusRepr (PBuiltinList PData)
ell)
PlutusRepr PPosixTimeRange
_ -> [Char] -> PLifted s PPosixTimeRange
forall a. HasCallStack => [Char] -> a
error [Char]
"Impossible: PPosixTimeRange is list-represented."
instance PTryFrom PData (PAsData PPosixTimeRange)