{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE UndecidableInstances #-}
module Plutarch.DataRepr.Internal.FromData (PFromDataable, pmaybeFromAsData) where
import Plutarch.Internal (PType, Term)
import Plutarch.Builtin (PAsData, PIsData, pfromData)
class PFromDataable (a :: PType) (b :: PType) | b -> a, a -> b where
pmaybeFromAsData :: Term s (PAsData a) -> Term s b
instance {-# OVERLAPPABLE #-} PFromDataable a (PAsData a) where
pmaybeFromAsData :: forall (s :: S). Term s (PAsData a) -> Term s (PAsData a)
pmaybeFromAsData = forall a. a -> a
id
instance {-# OVERLAPPABLE #-} (PIsData a, b ~ a) => PFromDataable a b where
pmaybeFromAsData :: forall (s :: S). Term s (PAsData a) -> Term s b
pmaybeFromAsData = forall (a :: PType) (s :: S).
PIsData a =>
Term s (PAsData a) -> Term s a
pfromData