plutus-core-0.1.0.0: Language library for Plutus Core
Safe HaskellNone
LanguageHaskell2010

PlutusCore.Builtin.Debug

Description

This module helps to visualize and debug the TypeScheme inference machinery from the Meaning module.

Synopsis

Documentation

elaborateDebug :: forall a j. ElaborateFromTo 0 j (Term TyName Name DefaultUni DefaultFun ()) a => a -> a Source #

Instantiate type variables in the type of a value using ElaborateFromTo. Example usages:

>>> :t elaborateDebug False
elaborateDebug False :: Bool
>>> :t elaborateDebug $ \_ -> ()
elaborateDebug $ \_ -> ()
  :: Opaque
       (Term TyName Name DefaultUni DefaultFun ())
       (TyVarRep ('TyNameRep "a" 0))
     -> ()
>>> :t elaborateDebug $ Just ()
<interactive>:1:1: error:
    • No instance for ‘KnownTypeAst DefaultUni (Maybe ())’
      Which means
        ‘Maybe ()’
      is neither a built-in type, nor one of the control types.
      If it can be represented in terms of one of the built-in types
        then go add the instance (you may need a ‘KnownTypeIn’ one too)
        alongside the instance for the built-in type.
      Otherwise you may need to add a new built-in type
        (provided you're doing something that can be supported in principle)
    • In the expression: elaborateDebug $ Just ()
>>> :t elaborateDebug $ 0 + 42
<interactive>:1:18: error:
    • Built-in functions are not allowed to have constraints
      To fix this error instantiate all constrained type variables
    • In the second argument of ‘($)’, namely ‘0 + 42’
      In the expression: elaborateDebug $ 0 + 42

newtype Opaque val (rep :: Type) Source #

The denotation of a term whose PLC type is encoded in rep (for example a type variable or an application of a type variable). I.e. the denotation of such a term is the term itself. This is because we have parametricity in Haskell, so we can't inspect a value whose type is, say, a bound variable, so we never need to convert such a term from Plutus Core to Haskell and back and instead can keep it intact.

Constructors

Opaque 

Fields

Instances

Instances details
uni ~ UniOf val => KnownTypeIn uni val (Opaque val rep) Source # 
Instance details

Defined in PlutusCore.Builtin.KnownType

Methods

makeKnown :: (MonadError (ErrorWithCause err cause) m, AsEvaluationFailure err) => (Text -> m ()) -> Maybe cause -> Opaque val rep -> m val Source #

readKnown :: (AsUnliftingError err, AsEvaluationFailure err) => Maybe cause -> val -> Either (ErrorWithCause err cause) (Opaque val rep) Source #

KnownTypeAst uni rep => KnownTypeAst uni (Opaque val rep :: Type) Source # 
Instance details

Defined in PlutusCore.Builtin.KnownTypeAst

Associated Types

type ToHoles (Opaque val rep) :: [Hole] Source #

type ToBinds (Opaque val rep) :: [Some TyNameRep] Source #

Methods

toTypeAst :: proxy (Opaque val rep) -> Type0 TyName uni () Source #

(TypeError NoConstraintsErrMsg :: Constraint) => Bounded (Opaque val rep) Source # 
Instance details

Defined in PlutusCore.Builtin.Polymorphism

Methods

minBound :: Opaque val rep Source #

maxBound :: Opaque val rep Source #

(TypeError NoConstraintsErrMsg :: Constraint) => Enum (Opaque val rep) Source # 
Instance details

Defined in PlutusCore.Builtin.Polymorphism

Methods

succ :: Opaque val rep -> Opaque val rep Source #

pred :: Opaque val rep -> Opaque val rep Source #

toEnum :: Int -> Opaque val rep Source #

fromEnum :: Opaque val rep -> Int Source #

enumFrom :: Opaque val rep -> [Opaque val rep] Source #

enumFromThen :: Opaque val rep -> Opaque val rep -> [Opaque val rep] Source #

enumFromTo :: Opaque val rep -> Opaque val rep -> [Opaque val rep] Source #

enumFromThenTo :: Opaque val rep -> Opaque val rep -> Opaque val rep -> [Opaque val rep] Source #

(TypeError NoConstraintsErrMsg :: Constraint) => Eq (Opaque val rep) Source # 
Instance details

Defined in PlutusCore.Builtin.Polymorphism

Methods

(==) :: Opaque val rep -> Opaque val rep -> Bool Source #

(/=) :: Opaque val rep -> Opaque val rep -> Bool Source #

(TypeError NoConstraintsErrMsg :: Constraint) => Integral (Opaque val rep) Source # 
Instance details

Defined in PlutusCore.Builtin.Polymorphism

Methods

quot :: Opaque val rep -> Opaque val rep -> Opaque val rep Source #

rem :: Opaque val rep -> Opaque val rep -> Opaque val rep Source #

div :: Opaque val rep -> Opaque val rep -> Opaque val rep Source #

mod :: Opaque val rep -> Opaque val rep -> Opaque val rep Source #

quotRem :: Opaque val rep -> Opaque val rep -> (Opaque val rep, Opaque val rep) Source #

divMod :: Opaque val rep -> Opaque val rep -> (Opaque val rep, Opaque val rep) Source #

toInteger :: Opaque val rep -> Integer Source #

(TypeError NoConstraintsErrMsg :: Constraint) => Num (Opaque val rep) Source # 
Instance details

Defined in PlutusCore.Builtin.Polymorphism

Methods

(+) :: Opaque val rep -> Opaque val rep -> Opaque val rep Source #

(-) :: Opaque val rep -> Opaque val rep -> Opaque val rep Source #

(*) :: Opaque val rep -> Opaque val rep -> Opaque val rep Source #

negate :: Opaque val rep -> Opaque val rep Source #

abs :: Opaque val rep -> Opaque val rep Source #

signum :: Opaque val rep -> Opaque val rep Source #

fromInteger :: Integer -> Opaque val rep Source #

(TypeError NoConstraintsErrMsg :: Constraint) => Ord (Opaque val rep) Source # 
Instance details

Defined in PlutusCore.Builtin.Polymorphism

Methods

compare :: Opaque val rep -> Opaque val rep -> Ordering Source #

(<) :: Opaque val rep -> Opaque val rep -> Bool Source #

(<=) :: Opaque val rep -> Opaque val rep -> Bool Source #

(>) :: Opaque val rep -> Opaque val rep -> Bool Source #

(>=) :: Opaque val rep -> Opaque val rep -> Bool Source #

max :: Opaque val rep -> Opaque val rep -> Opaque val rep Source #

min :: Opaque val rep -> Opaque val rep -> Opaque val rep Source #

(TypeError NoConstraintsErrMsg :: Constraint) => Real (Opaque val rep) Source # 
Instance details

Defined in PlutusCore.Builtin.Polymorphism

Methods

toRational :: Opaque val rep -> Rational Source #

(TypeError NoConstraintsErrMsg :: Constraint) => Ix (Opaque val rep) Source # 
Instance details

Defined in PlutusCore.Builtin.Polymorphism

Methods

range :: (Opaque val rep, Opaque val rep) -> [Opaque val rep] Source #

index :: (Opaque val rep, Opaque val rep) -> Opaque val rep -> Int Source #

unsafeIndex :: (Opaque val rep, Opaque val rep) -> Opaque val rep -> Int Source #

inRange :: (Opaque val rep, Opaque val rep) -> Opaque val rep -> Bool Source #

rangeSize :: (Opaque val rep, Opaque val rep) -> Int Source #

unsafeRangeSize :: (Opaque val rep, Opaque val rep) -> Int Source #

(TypeError NoConstraintsErrMsg :: Constraint) => Semigroup (Opaque val rep) Source # 
Instance details

Defined in PlutusCore.Builtin.Polymorphism

Methods

(<>) :: Opaque val rep -> Opaque val rep -> Opaque val rep Source #

sconcat :: NonEmpty (Opaque val rep) -> Opaque val rep Source #

stimes :: Integral b => b -> Opaque val rep -> Opaque val rep Source #

(TypeError NoConstraintsErrMsg :: Constraint) => Monoid (Opaque val rep) Source # 
Instance details

Defined in PlutusCore.Builtin.Polymorphism

Methods

mempty :: Opaque val rep Source #

mappend :: Opaque val rep -> Opaque val rep -> Opaque val rep Source #

mconcat :: [Opaque val rep] -> Opaque val rep Source #

Pretty val => Pretty (Opaque val rep) Source # 
Instance details

Defined in PlutusCore.Builtin.Polymorphism

Methods

pretty :: Opaque val rep -> Doc ann Source #

prettyList :: [Opaque val rep] -> Doc ann Source #

FromConstant val => FromConstant (Opaque val rep) Source # 
Instance details

Defined in PlutusCore.Builtin.Polymorphism

Methods

fromConstant :: Some (ValueOf (UniOf (Opaque val rep))) -> Opaque val rep Source #

AsConstant val => AsConstant (Opaque val rep) Source # 
Instance details

Defined in PlutusCore.Builtin.Polymorphism

Methods

asConstant :: (MonadError (ErrorWithCause err cause) m, AsUnliftingError err) => Maybe cause -> Opaque val rep -> m (Some (ValueOf (UniOf (Opaque val rep)))) Source #

type ToHoles (Opaque val rep :: Type) Source # 
Instance details

Defined in PlutusCore.Builtin.KnownTypeAst

type ToHoles (Opaque val rep :: Type) = '[RepHole rep :: Hole]
type ToBinds (Opaque val rep :: Type) Source # 
Instance details

Defined in PlutusCore.Builtin.KnownTypeAst

type ToBinds (Opaque val rep :: Type) = ToBinds rep
type UniOf (Opaque val rep) Source # 
Instance details

Defined in PlutusCore.Builtin.Polymorphism

type UniOf (Opaque val rep) = UniOf val

newtype SomeConstant uni (rep :: Type) Source #

For unlifting from the Constant constructor when the stored value is of a monomorphic built-in type

The rep parameter specifies how the type looks on the PLC side (i.e. just like with Opaque val rep).

Constructors

SomeConstant 

Fields

Instances

Instances details
HasConstantIn uni val => KnownTypeIn uni val (SomeConstant uni rep) Source # 
Instance details

Defined in PlutusCore.Builtin.KnownType

Methods

makeKnown :: (MonadError (ErrorWithCause err cause) m, AsEvaluationFailure err) => (Text -> m ()) -> Maybe cause -> SomeConstant uni rep -> m val Source #

readKnown :: (AsUnliftingError err, AsEvaluationFailure err) => Maybe cause -> val -> Either (ErrorWithCause err cause) (SomeConstant uni rep) Source #

KnownTypeAst uni rep => KnownTypeAst uni (SomeConstant uni rep :: Type) Source # 
Instance details

Defined in PlutusCore.Builtin.KnownTypeAst

Associated Types

type ToHoles (SomeConstant uni rep) :: [Hole] Source #

type ToBinds (SomeConstant uni rep) :: [Some TyNameRep] Source #

Methods

toTypeAst :: proxy (SomeConstant uni rep) -> Type0 TyName uni () Source #

type ToHoles (SomeConstant uni rep :: Type) Source # 
Instance details

Defined in PlutusCore.Builtin.KnownTypeAst

type ToHoles (SomeConstant uni rep :: Type) = '[RepHole rep :: Hole]
type ToBinds (SomeConstant uni rep :: Type) Source # 
Instance details

Defined in PlutusCore.Builtin.KnownTypeAst

type ToBinds (SomeConstant uni rep :: Type) = ToBinds rep

data TyNameRep (kind :: Type) Source #

Representation of a type variable: its name and unique and an implicit kind.

Constructors

TyNameRep Symbol Nat 

Instances

Instances details
KnownMonotype val args res a => KnownPolytype ('[] :: [Some TyNameRep]) val args res (a :: k) Source #

Once we've run out of type-level arguments, we start handling term-level ones.

Instance details

Defined in PlutusCore.Builtin.Meaning

Methods

knownPolytype :: Proxy '[] -> TypeScheme val args res Source #

(KnownSymbol name, KnownNat uniq, KnownKind kind, KnownPolytype binds val args res a) => KnownPolytype ('Some ('TyNameRep name uniq :: TyNameRep kind) ': binds) val args res (a :: k) Source #

Every type-level argument becomes a TypeSchemeAll.

Instance details

Defined in PlutusCore.Builtin.Meaning

Methods

knownPolytype :: Proxy ('Some ('TyNameRep name uniq) ': binds) -> TypeScheme val args res Source #

(TypeError NoStandalonePolymorphicDataErrMsg :: Constraint) => Contains uni (TyVarRep :: TyNameRep kind -> kind) Source # 
Instance details

Defined in PlutusCore.Builtin.Polymorphism

Methods

knownUni :: uni (Esc TyVarRep) Source #

data family TyVarRep (name :: TyNameRep kind) :: kind Source #

Representation of an intrinsically-kinded type variable: a name.

Instances

Instances details
(name ~ ('TyNameRep text uniq :: TyNameRep a), KnownSymbol text, KnownNat uniq) => KnownTypeAst uni (TyVarRep name :: a) Source # 
Instance details

Defined in PlutusCore.Builtin.KnownTypeAst

Associated Types

type ToHoles (TyVarRep name) :: [Hole] Source #

type ToBinds (TyVarRep name) :: [Some TyNameRep] Source #

Methods

toTypeAst :: proxy (TyVarRep name) -> Type TyName uni () Source #

(TypeError NoStandalonePolymorphicDataErrMsg :: Constraint) => Contains uni (TyVarRep :: TyNameRep kind -> kind) Source # 
Instance details

Defined in PlutusCore.Builtin.Polymorphism

Methods

knownUni :: uni (Esc TyVarRep) Source #

type ToHoles (TyVarRep name :: a) Source # 
Instance details

Defined in PlutusCore.Builtin.KnownTypeAst

type ToHoles (TyVarRep name :: a) = '[] :: [Hole]
type ToBinds (TyVarRep name :: a) Source # 
Instance details

Defined in PlutusCore.Builtin.KnownTypeAst

type ToBinds (TyVarRep name :: a) = '['Some name]

data family TyAppRep (fun :: dom -> cod) (arg :: dom) :: cod Source #

Representation of an intrinsically-kinded type application: a function and an argument.

Instances

Instances details
(KnownTypeAst uni fun, KnownTypeAst uni arg) => KnownTypeAst uni (TyAppRep fun arg :: a) Source # 
Instance details

Defined in PlutusCore.Builtin.KnownTypeAst

Associated Types

type ToHoles (TyAppRep fun arg) :: [Hole] Source #

type ToBinds (TyAppRep fun arg) :: [Some TyNameRep] Source #

Methods

toTypeAst :: proxy (TyAppRep fun arg) -> Type TyName uni () Source #

type ToHoles (TyAppRep fun arg :: a) Source # 
Instance details

Defined in PlutusCore.Builtin.KnownTypeAst

type ToHoles (TyAppRep fun arg :: a) = '[RepHole fun :: Hole, RepHole arg :: Hole]
type ToBinds (TyAppRep fun arg :: a) Source # 
Instance details

Defined in PlutusCore.Builtin.KnownTypeAst

type ToBinds (TyAppRep fun arg :: a) = Merge (ToBinds fun) (ToBinds arg)

data family TyForallRep (name :: TyNameRep kind) (a :: Type) :: Type Source #

Representation of of an intrinsically-kinded universal quantifier: a bound name and a body.

Instances

Instances details
(name ~ ('TyNameRep text uniq :: TyNameRep kind), KnownSymbol text, KnownNat uniq, KnownKind kind, KnownTypeAst uni a) => KnownTypeAst uni (TyForallRep name a :: Type) Source # 
Instance details

Defined in PlutusCore.Builtin.KnownTypeAst

Associated Types

type ToHoles (TyForallRep name a) :: [Hole] Source #

type ToBinds (TyForallRep name a) :: [Some TyNameRep] Source #

Methods

toTypeAst :: proxy (TyForallRep name a) -> Type0 TyName uni () Source #

type ToHoles (TyForallRep name a :: Type) Source # 
Instance details

Defined in PlutusCore.Builtin.KnownTypeAst

type ToHoles (TyForallRep name a :: Type) = '[RepHole a :: Hole]
type ToBinds (TyForallRep name a :: Type) Source # 
Instance details

Defined in PlutusCore.Builtin.KnownTypeAst

type ToBinds (TyForallRep name a :: Type)