Safe Haskell | None |
---|---|
Language | Haskell2010 |
Support for using de Bruijn indices for term names.
Synopsis
- newtype Index = Index Word64
- class HasIndex a where
- newtype DeBruijn = DeBruijn { }
-
data
NamedDeBruijn
=
NamedDeBruijn
{
- ndbnString :: Text
- ndbnIndex :: Index
- newtype FakeNamedDeBruijn = FakeNamedDeBruijn NamedDeBruijn
- data FreeVariableError
-
class
AsFreeVariableError
r
where
- _FreeVariableError :: Prism' r FreeVariableError
- _FreeUnique :: Prism' r Unique
- _FreeIndex :: Prism' r Index
- deBruijnTerm :: ( AsFreeVariableError e, MonadError e m) => Term Name uni fun ann -> m ( Term NamedDeBruijn uni fun ann)
- unDeBruijnTerm :: ( MonadQuote m, AsFreeVariableError e, MonadError e m) => Term NamedDeBruijn uni fun ann -> m ( Term Name uni fun ann)
- unNameDeBruijn :: NamedDeBruijn -> DeBruijn
- fakeNameDeBruijn :: DeBruijn -> NamedDeBruijn
- deBruijnTermWith :: Monad m => ( Unique -> ReaderT Levels m Index ) -> Term Name uni fun ann -> m ( Term NamedDeBruijn uni fun ann)
- unDeBruijnTermWith :: MonadQuote m => ( Index -> ReaderT Levels m Unique ) -> Term NamedDeBruijn uni fun ann -> m ( Term Name uni fun ann)
- freeIndexAsConsistentLevel :: ( MonadReader Levels m, MonadState ( Map Level Unique ) m, MonadQuote m) => Index -> m Unique
- deBruijnInitIndex :: Index
Documentation
A relative index used for de Bruijn identifiers.
Instances
Enum Index Source # | |
Defined in PlutusCore.DeBruijn.Internal succ :: Index -> Index Source # pred :: Index -> Index Source # toEnum :: Int -> Index Source # fromEnum :: Index -> Int Source # enumFrom :: Index -> [ Index ] Source # enumFromThen :: Index -> Index -> [ Index ] Source # enumFromTo :: Index -> Index -> [ Index ] Source # enumFromThenTo :: Index -> Index -> Index -> [ Index ] Source # |
|
Eq Index Source # | |
Integral Index Source # | |
Defined in PlutusCore.DeBruijn.Internal |
|
Num Index Source # | |
Ord Index Source # | |
Defined in PlutusCore.DeBruijn.Internal |
|
Real Index Source # | |
Defined in PlutusCore.DeBruijn.Internal toRational :: Index -> Rational Source # |
|
Show Index Source # | |
Generic Index Source # | |
NFData Index Source # | |
Defined in PlutusCore.DeBruijn.Internal |
|
Flat Index Source # | |
Pretty Index Source # | |
type Rep Index Source # | |
Defined in PlutusCore.DeBruijn.Internal |
class HasIndex a where Source #
Instances
HasIndex TyDeBruijn Source # | |
Defined in PlutusCore.DeBruijn.Internal |
|
HasIndex NamedTyDeBruijn Source # | |
Defined in PlutusCore.DeBruijn.Internal |
|
HasIndex DeBruijn Source # | |
HasIndex NamedDeBruijn Source # | |
Defined in PlutusCore.DeBruijn.Internal |
A term name as a de Bruijn index, without the name string.
Instances
Eq DeBruijn Source # | |
Show DeBruijn Source # | |
Generic DeBruijn Source # | |
NFData DeBruijn Source # | |
Defined in PlutusCore.DeBruijn.Internal |
|
Flat DeBruijn Source # | |
HasIndex DeBruijn Source # | |
HasPrettyConfigName config => PrettyBy config DeBruijn Source # | |
Flat ( Binder DeBruijn ) Source # | |
( GEq uni, Closed uni, Everywhere uni Eq , Eq fun, Eq ann) => Eq ( Term DeBruijn uni fun ann) Source # | |
( GEq uni, Closed uni, Everywhere uni Eq , Eq fun, Eq ann) => Eq ( Term TyDeBruijn DeBruijn uni fun ann) Source # | |
Defined in PlutusCore.Core.Instance.Eq (==) :: Term TyDeBruijn DeBruijn uni fun ann -> Term TyDeBruijn DeBruijn uni fun ann -> Bool Source # (/=) :: Term TyDeBruijn DeBruijn uni fun ann -> Term TyDeBruijn DeBruijn uni fun ann -> Bool Source # |
|
type Rep DeBruijn Source # | |
Defined in PlutusCore.DeBruijn.Internal |
data NamedDeBruijn Source #
A term name as a de Bruijn index.
Instances
newtype FakeNamedDeBruijn Source #
A wrapper around nameddebruijn that must hold the invariant of name=
fakeName
.
Instances
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
class AsFreeVariableError r where Source #
_FreeVariableError :: Prism' r FreeVariableError Source #
_FreeUnique :: Prism' r Unique Source #
_FreeIndex :: Prism' r Index Source #
Instances
AsFreeVariableError FreeVariableError Source # | |
AsFreeVariableError ( Error uni fun ann) Source # | |
Defined in PlutusCore.Error _FreeVariableError :: Prism' ( Error uni fun ann) FreeVariableError Source # |
|
AsFreeVariableError ( Error uni fun a) Source # | |
Defined in PlutusIR.Error _FreeVariableError :: Prism' ( Error uni fun a) FreeVariableError Source # |
deBruijnTerm :: ( AsFreeVariableError e, MonadError e m) => Term Name uni fun ann -> m ( Term NamedDeBruijn uni fun ann) Source #
unDeBruijnTerm :: ( MonadQuote m, AsFreeVariableError e, MonadError e m) => Term NamedDeBruijn uni fun ann -> m ( Term Name uni fun ann) Source #
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