plutus-core-1.0.0.1: Language library for Plutus Core
Safe Haskell None
Language Haskell2010

UntypedPlutusCore.DeBruijn

Description

Support for using de Bruijn indices for term names.

Synopsis

Documentation

newtype Index Source #

A relative index used for de Bruijn identifiers.

Constructors

Index Word64

Instances

Instances details
Enum Index Source #
Instance details

Defined in PlutusCore.DeBruijn.Internal

Eq Index Source #
Instance details

Defined in PlutusCore.DeBruijn.Internal

Integral Index Source #
Instance details

Defined in PlutusCore.DeBruijn.Internal

Num Index Source #
Instance details

Defined in PlutusCore.DeBruijn.Internal

Ord Index Source #
Instance details

Defined in PlutusCore.DeBruijn.Internal

Real Index Source #
Instance details

Defined in PlutusCore.DeBruijn.Internal

Show Index Source #
Instance details

Defined in PlutusCore.DeBruijn.Internal

Generic Index Source #
Instance details

Defined in PlutusCore.DeBruijn.Internal

NFData Index Source #
Instance details

Defined in PlutusCore.DeBruijn.Internal

Flat Index Source #
Instance details

Defined in PlutusCore.Flat

Pretty Index Source #
Instance details

Defined in PlutusCore.DeBruijn.Internal

type Rep Index Source #
Instance details

Defined in PlutusCore.DeBruijn.Internal

type Rep Index = D1 (' MetaData "Index" "PlutusCore.DeBruijn.Internal" "plutus-core-1.0.0.1-76bWF9ZEWyb4eDyjHx0kCS" ' True ) ( C1 (' MetaCons "Index" ' PrefixI ' False ) ( S1 (' MetaSel (' Nothing :: Maybe Symbol ) ' NoSourceUnpackedness ' NoSourceStrictness ' DecidedLazy ) ( Rec0 Word64 )))

newtype DeBruijn Source #

A term name as a de Bruijn index, without the name string.

Constructors

DeBruijn

Instances

Instances details
Eq DeBruijn Source #
Instance details

Defined in PlutusCore.DeBruijn.Internal

Show DeBruijn Source #
Instance details

Defined in PlutusCore.DeBruijn.Internal

Generic DeBruijn Source #
Instance details

Defined in PlutusCore.DeBruijn.Internal

NFData DeBruijn Source #
Instance details

Defined in PlutusCore.DeBruijn.Internal

Flat DeBruijn Source #
Instance details

Defined in PlutusCore.Flat

HasIndex DeBruijn Source #
Instance details

Defined in PlutusCore.DeBruijn.Internal

HasPrettyConfigName config => PrettyBy config DeBruijn Source #
Instance details

Defined in PlutusCore.DeBruijn.Internal

Flat ( Binder DeBruijn ) Source #
Instance details

Defined in PlutusCore.Flat

( GEq uni, Closed uni, Everywhere uni Eq , Eq fun, Eq ann) => Eq ( Term DeBruijn uni fun ann) Source #
Instance details

Defined in UntypedPlutusCore.Core.Instance.Eq

( GEq uni, Closed uni, Everywhere uni Eq , Eq fun, Eq ann) => Eq ( Term TyDeBruijn DeBruijn uni fun ann) Source #
Instance details

Defined in PlutusCore.Core.Instance.Eq

type Rep DeBruijn Source #
Instance details

Defined in PlutusCore.DeBruijn.Internal

type Rep DeBruijn = D1 (' MetaData "DeBruijn" "PlutusCore.DeBruijn.Internal" "plutus-core-1.0.0.1-76bWF9ZEWyb4eDyjHx0kCS" ' True ) ( C1 (' MetaCons "DeBruijn" ' PrefixI ' True ) ( S1 (' MetaSel (' Just "dbnIndex") ' NoSourceUnpackedness ' NoSourceStrictness ' DecidedLazy ) ( Rec0 Index )))

data NamedDeBruijn Source #

A term name as a de Bruijn index.

Instances

Instances details
Eq NamedDeBruijn Source #
Instance details

Defined in PlutusCore.DeBruijn.Internal

Show NamedDeBruijn Source #
Instance details

Defined in PlutusCore.DeBruijn.Internal

Generic NamedDeBruijn Source #
Instance details

Defined in PlutusCore.DeBruijn.Internal

NFData NamedDeBruijn Source #
Instance details

Defined in PlutusCore.DeBruijn.Internal

Flat NamedDeBruijn Source #
Instance details

Defined in PlutusCore.Flat

HasIndex NamedDeBruijn Source #
Instance details

Defined in PlutusCore.DeBruijn.Internal

HasPrettyConfigName config => PrettyBy config NamedDeBruijn Source #
Instance details

Defined in PlutusCore.DeBruijn.Internal

Flat ( Binder NamedDeBruijn ) Source #
Instance details

Defined in PlutusCore.Flat

PrettyUni uni fun => MonadError ( CekEvaluationException NamedDeBruijn uni fun) ( CekM uni fun s) Source #
Instance details

Defined in UntypedPlutusCore.Evaluation.Machine.Cek.Internal

( GEq uni, Closed uni, Everywhere uni Eq , Eq fun, Eq ann) => Eq ( Term NamedDeBruijn uni fun ann) Source #
Instance details

Defined in UntypedPlutusCore.Core.Instance.Eq

( GEq uni, Closed uni, Everywhere uni Eq , Eq fun, Eq ann) => Eq ( Term NamedTyDeBruijn NamedDeBruijn uni fun ann) Source #
Instance details

Defined in PlutusCore.Core.Instance.Eq

type Rep NamedDeBruijn Source #
Instance details

Defined in PlutusCore.DeBruijn.Internal

type Rep NamedDeBruijn = D1 (' MetaData "NamedDeBruijn" "PlutusCore.DeBruijn.Internal" "plutus-core-1.0.0.1-76bWF9ZEWyb4eDyjHx0kCS" ' False ) ( C1 (' MetaCons "NamedDeBruijn" ' PrefixI ' True ) ( S1 (' MetaSel (' Just "ndbnString") ' NoSourceUnpackedness ' NoSourceStrictness ' DecidedLazy ) ( Rec0 Text ) :*: S1 (' MetaSel (' Just "ndbnIndex") ' NoSourceUnpackedness ' NoSourceStrictness ' DecidedLazy ) ( Rec0 Index )))

newtype FakeNamedDeBruijn Source #

A wrapper around nameddebruijn that must hold the invariant of name= fakeName .

Instances

Instances details
Eq FakeNamedDeBruijn Source #
Instance details

Defined in PlutusCore.DeBruijn.Internal

Show FakeNamedDeBruijn Source #
Instance details

Defined in PlutusCore.DeBruijn.Internal

NFData FakeNamedDeBruijn Source #
Instance details

Defined in PlutusCore.DeBruijn.Internal

Flat FakeNamedDeBruijn Source #
Instance details

Defined in PlutusCore.Flat

HasPrettyConfigName config => PrettyBy config FakeNamedDeBruijn Source #
Instance details

Defined in PlutusCore.DeBruijn.Internal

Flat ( Binder FakeNamedDeBruijn ) Source #
Instance details

Defined in PlutusCore.Flat

( GEq uni, Closed uni, Everywhere uni Eq , Eq fun, Eq ann) => Eq ( Term FakeNamedDeBruijn uni fun ann) Source #
Instance details

Defined in UntypedPlutusCore.Core.Instance.Eq

data FreeVariableError Source #

We cannot do a correct translation to or from de Bruijn indices if the program is not well-scoped. So we throw an error in such a case.

Instances

Instances details
Eq FreeVariableError Source #
Instance details

Defined in PlutusCore.DeBruijn.Internal

Ord FreeVariableError Source #
Instance details

Defined in PlutusCore.DeBruijn.Internal

Show FreeVariableError Source #
Instance details

Defined in PlutusCore.DeBruijn.Internal

Generic FreeVariableError Source #
Instance details

Defined in PlutusCore.DeBruijn.Internal

Exception FreeVariableError Source #
Instance details

Defined in PlutusCore.DeBruijn.Internal

NFData FreeVariableError Source #
Instance details

Defined in PlutusCore.DeBruijn.Internal

Pretty FreeVariableError Source #
Instance details

Defined in PlutusCore.DeBruijn.Internal

HasErrorCode FreeVariableError Source #
Instance details

Defined in PlutusCore.DeBruijn.Internal

AsFreeVariableError FreeVariableError Source #
Instance details

Defined in PlutusCore.DeBruijn.Internal

type Rep FreeVariableError Source #
Instance details

Defined in PlutusCore.DeBruijn.Internal

deBruijnTerm :: ( AsFreeVariableError e, MonadError e m) => Term Name uni fun ann -> m ( Term NamedDeBruijn uni fun ann) Source #

Convert a Term with Name s into a Term with DeBruijn s. Will throw an error if a free variable is encountered.

unDeBruijnTerm :: ( MonadQuote m, AsFreeVariableError e, MonadError e m) => Term NamedDeBruijn uni fun ann -> m ( Term Name uni fun ann) Source #

Convert a Term with DeBruijn s into a Term with Name s. Will throw an error if a free variable is encountered.

unsafe api, use with care

deBruijnTermWith :: Monad m => ( Unique -> ReaderT Levels m Index ) -> Term Name uni fun ann -> m ( Term NamedDeBruijn uni fun ann) Source #

Takes a "handler" function to execute when encountering free variables.

unDeBruijnTermWith :: MonadQuote m => ( Index -> ReaderT Levels m Unique ) -> Term NamedDeBruijn uni fun ann -> m ( Term Name uni fun ann) Source #

Takes a "handler" function to execute when encountering free variables.

freeIndexAsConsistentLevel :: ( MonadReader Levels m, MonadState ( Map Level Unique ) m, MonadQuote m) => Index -> m Unique Source #

A different implementation of a handler, where "free" debruijn indices do not throw an error but are instead gracefully converted to fresh uniques. These generated uniques remain free; i.e. if the original term was open, it will remain open after applying this handler. These generated free uniques are consistent across the open term (by using a state cache).

deBruijnInitIndex :: Index Source #

The LamAbs index (for debruijn indices) and the starting level of DeBruijn monad