module Cooked.Skeleton.Payable
( Payable (..),
(<&&>),
)
where
import Cooked.Conversion
import Cooked.Skeleton.Datum
import Data.Kind (Constraint, Type)
import GHC.TypeLits
type family (∉) (el :: a) (els :: [a]) :: Constraint where
x ∉ '[] = ()
x ∉ (x ': xs) = TypeError ('Text "Cannot have two payable elements of type: " ':<>: 'ShowType x)
x ∉ (_ ': xs) = x ∉ xs
type family (⩀) (els :: [a]) (els' :: [a]) :: Constraint where
'[] ⩀ _ = ()
(x ': xs) ⩀ ys = (x ∉ ys, xs ⩀ ys)
type family (∪) (xs :: [a]) (ys :: [a]) :: [a] where
'[] ∪ ys = ys
(x ': xs) ∪ ys = x ': (xs ∪ ys)
data Payable :: [Symbol] -> Type where
VisibleHashedDatum :: (TxSkelOutDatumConstrs a) => a -> Payable '["Datum"]
InlineDatum :: (TxSkelOutDatumConstrs a) => a -> Payable '["Datum"]
HiddenHashedDatum :: (TxSkelOutDatumConstrs a) => a -> Payable '["Datum"]
ReferenceScript :: (ToVersionedScript s) => s -> Payable '["Reference Script"]
Value :: (ToValue a) => a -> Payable '["Value"]
FixedValue :: (ToValue a) => a -> Payable '["Value"]
StakingCredential :: (ToMaybeStakingCredential cred) => cred -> Payable '["Staking Credential"]
PayableAnd :: (els ⩀ els') => Payable els -> Payable els' -> Payable (els ∪ els')
(<&&>) :: (els ⩀ els') => Payable els -> Payable els' -> Payable (els ∪ els')
<&&> :: forall (els :: [Symbol]) (els' :: [Symbol]).
(els ⩀ els') =>
Payable els -> Payable els' -> Payable (els ∪ els')
(<&&>) = Payable els -> Payable els' -> Payable (els ∪ els')
forall (els :: [Symbol]) (els' :: [Symbol]).
(els ⩀ els') =>
Payable els -> Payable els' -> Payable (els ∪ els')
PayableAnd