plutus-core-1.0.0.1: 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
(TypeError NoRegularlyAppliedHkVarsMsg :: Constraint) => Bitraversable Opaque Source # 
Instance details

Defined in PlutusCore.Builtin.Polymorphism

Methods

bitraverse :: Applicative f => (a -> f c) -> (b -> f d) -> Opaque a b -> f (Opaque c d) Source #

(TypeError NoRegularlyAppliedHkVarsMsg :: Constraint) => Bifoldable Opaque Source # 
Instance details

Defined in PlutusCore.Builtin.Polymorphism

Methods

bifold :: Monoid m => Opaque m m -> m Source #

bifoldMap :: Monoid m => (a -> m) -> (b -> m) -> Opaque a b -> m Source #

bifoldr :: (a -> c -> c) -> (b -> c -> c) -> c -> Opaque a b -> c Source #

bifoldl :: (c -> a -> c) -> (c -> b -> c) -> c -> Opaque a b -> c Source #

(TypeError NoRegularlyAppliedHkVarsMsg :: Constraint) => Bifunctor Opaque Source # 
Instance details

Defined in PlutusCore.Builtin.Polymorphism

Methods

bimap :: (a -> b) -> (c -> d) -> Opaque a c -> Opaque b d Source #

first :: (a -> b) -> Opaque a c -> Opaque b c Source #

second :: (b -> c) -> Opaque a b -> Opaque a c Source #

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

Defined in PlutusCore.Builtin.KnownType

Methods

readKnown :: Maybe cause -> val -> ReadKnownM cause (Opaque val rep) Source #

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

Defined in PlutusCore.Builtin.KnownType

Methods

makeKnown :: Maybe cause -> Opaque val rep -> MakeKnownM cause val Source #

(TypeError NoRegularlyAppliedHkVarsMsg :: Constraint) => Monad (Opaque val) Source # 
Instance details

Defined in PlutusCore.Builtin.Polymorphism

Methods

(>>=) :: Opaque val a -> (a -> Opaque val b) -> Opaque val b Source #

(>>) :: Opaque val a -> Opaque val b -> Opaque val b Source #

return :: a -> Opaque val a Source #

(TypeError NoRegularlyAppliedHkVarsMsg :: Constraint) => Functor (Opaque val) Source # 
Instance details

Defined in PlutusCore.Builtin.Polymorphism

Methods

fmap :: (a -> b) -> Opaque val a -> Opaque val b Source #

(<$) :: a -> Opaque val b -> Opaque val a Source #

(TypeError NoRegularlyAppliedHkVarsMsg :: Constraint) => MonadFail (Opaque val) Source # 
Instance details

Defined in PlutusCore.Builtin.Polymorphism

Methods

fail :: String -> Opaque val a Source #

(TypeError NoRegularlyAppliedHkVarsMsg :: Constraint) => Applicative (Opaque val) Source # 
Instance details

Defined in PlutusCore.Builtin.Polymorphism

Methods

pure :: a -> Opaque val a Source #

(<*>) :: Opaque val (a -> b) -> Opaque val a -> Opaque val b Source #

liftA2 :: (a -> b -> c) -> Opaque val a -> Opaque val b -> Opaque val c Source #

(*>) :: Opaque val a -> Opaque val b -> Opaque val b Source #

(<*) :: Opaque val a -> Opaque val b -> Opaque val a Source #

(TypeError NoRegularlyAppliedHkVarsMsg :: Constraint) => Foldable (Opaque val) Source # 
Instance details

Defined in PlutusCore.Builtin.Polymorphism

Methods

fold :: Monoid m => Opaque val m -> m Source #

foldMap :: Monoid m => (a -> m) -> Opaque val a -> m Source #

foldMap' :: Monoid m => (a -> m) -> Opaque val a -> m Source #

foldr :: (a -> b -> b) -> b -> Opaque val a -> b Source #

foldr' :: (a -> b -> b) -> b -> Opaque val a -> b Source #

foldl :: (b -> a -> b) -> b -> Opaque val a -> b Source #

foldl' :: (b -> a -> b) -> b -> Opaque val a -> b Source #

foldr1 :: (a -> a -> a) -> Opaque val a -> a Source #

foldl1 :: (a -> a -> a) -> Opaque val a -> a Source #

toList :: Opaque val a -> [a] Source #

null :: Opaque val a -> Bool Source #

length :: Opaque val a -> Int Source #

elem :: Eq a => a -> Opaque val a -> Bool Source #

maximum :: Ord a => Opaque val a -> a Source #

minimum :: Ord a => Opaque val a -> a Source #

sum :: Num a => Opaque val a -> a Source #

product :: Num a => Opaque val a -> a Source #

(TypeError NoRegularlyAppliedHkVarsMsg :: Constraint) => Traversable (Opaque val) Source # 
Instance details

Defined in PlutusCore.Builtin.Polymorphism

Methods

traverse :: Applicative f => (a -> f b) -> Opaque val a -> f (Opaque val b) Source #

sequenceA :: Applicative f => Opaque val (f a) -> f (Opaque val a) Source #

mapM :: Monad m => (a -> m b) -> Opaque val a -> m (Opaque val b) Source #

sequence :: Monad m => Opaque val (m a) -> m (Opaque val a) Source #

(TypeError NoRegularlyAppliedHkVarsMsg :: Constraint) => MonadIO (Opaque val) Source # 
Instance details

Defined in PlutusCore.Builtin.Polymorphism

Methods

liftIO :: IO a -> Opaque val a Source #

(TypeError NoRegularlyAppliedHkVarsMsg :: Constraint) => Alternative (Opaque val) Source # 
Instance details

Defined in PlutusCore.Builtin.Polymorphism

Methods

empty :: Opaque val a Source #

(<|>) :: Opaque val a -> Opaque val a -> Opaque val a Source #

some :: Opaque val a -> Opaque val [a] Source #

many :: Opaque val a -> Opaque val [a] Source #

(TypeError NoRegularlyAppliedHkVarsMsg :: Constraint) => MonadPlus (Opaque val) Source # 
Instance details

Defined in PlutusCore.Builtin.Polymorphism

Methods

mzero :: Opaque val a Source #

mplus :: Opaque val a -> Opaque val a -> Opaque val a 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 #

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

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

Defined in PlutusCore.Builtin.Polymorphism

Methods

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

fromConstant :: Some (ValueOf (UniOf (Opaque val rep))) -> 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 => ReadKnownIn uni val (SomeConstant uni rep) Source # 
Instance details

Defined in PlutusCore.Builtin.KnownType

Methods

readKnown :: Maybe cause -> val -> ReadKnownM cause (SomeConstant uni rep) Source #

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

Defined in PlutusCore.Builtin.KnownType

Methods

makeKnown :: Maybe cause -> SomeConstant uni rep -> MakeKnownM cause val 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

(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

(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)