Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
The internal module of the renamer that defines the actual algorithms, but not the user-facing API.
Synopsis
- module PlutusCore.Rename.Monad
- newtype Renamed a = Renamed {
- unRenamed :: a
- newtype Dupable a = Dupable {
- unDupable :: a
- withFreshenedTyVarDecl :: (HasRenaming ren TypeUnique, HasUniques (Type tyname uni ann), MonadQuote m, MonadReader ren m) => TyVarDecl tyname ann -> (TyVarDecl tyname ann -> m c) -> m c
- withFreshenedVarDecl :: (HasUniques (Term tyname name uni fun ann), MonadQuote m, MonadReader ScopedRenaming m) => VarDecl tyname name uni ann -> (m (VarDecl tyname name uni ann) -> m c) -> m c
- renameTypeM :: (HasRenaming ren TypeUnique, HasUniques (Type tyname uni ann), MonadQuote m, MonadReader ren m) => Type tyname uni ann -> m (Type tyname uni ann)
- renameTermM :: (HasUniques (Term tyname name uni fun ann), MonadQuote m, MonadReader ScopedRenaming m) => Term tyname name uni fun ann -> m (Term tyname name uni fun ann)
- renameProgramM :: (HasUniques (Program tyname name uni fun ann), MonadQuote m, MonadReader ScopedRenaming m) => Program tyname name uni fun ann -> m (Program tyname name uni fun ann)
Documentation
module PlutusCore.Rename.Monad
A wrapper for signifying that the value inside of it satisfies global uniqueness.
It's safe to call unRenamed
, it's not safe to call Renamed
, hence the latter is only exported
from this internal module and should not be exported from the main API.
Don't provide any instances allowing the user to create a Renamed
(even out of an existing one
like with Functor
).
Dupable a
is isomorphic to a
, but the only way to extract the a
is via liftDupable
(defined in the main API module because of a constraint requirement) which renames the stored
value along the way. This type is used whenever
- preserving global uniqueness is required
- some value may be used multiple times
so we annotate such a value with Dupable
and call liftDupable
at each usage, which ensures
global uniqueness is preserved.
unDupable
is not supposed to be exported. Don't provide any instances allowing the user to
access the underlying value.
withFreshenedTyVarDecl :: (HasRenaming ren TypeUnique, HasUniques (Type tyname uni ann), MonadQuote m, MonadReader ren m) => TyVarDecl tyname ann -> (TyVarDecl tyname ann -> m c) -> m c Source #
withFreshenedVarDecl :: (HasUniques (Term tyname name uni fun ann), MonadQuote m, MonadReader ScopedRenaming m) => VarDecl tyname name uni ann -> (m (VarDecl tyname name uni ann) -> m c) -> m c Source #
Replace the unique in the name stored in a VarDecl
by a new unique, save the mapping
from the old unique to the new one and supply to a continuation the computation that
renames the type stored in the updated VarDecl
.
The reason the continuation receives a computation rather than a pure term is that we may want
to bring several term and type variables in scope before renaming the types of term variables.
This situation arises when we want to rename a bunch of mutually recursive bindings.
renameTypeM :: (HasRenaming ren TypeUnique, HasUniques (Type tyname uni ann), MonadQuote m, MonadReader ren m) => Type tyname uni ann -> m (Type tyname uni ann) Source #
Rename a Kind
in the RenameM
monad.
renameTermM :: (HasUniques (Term tyname name uni fun ann), MonadQuote m, MonadReader ScopedRenaming m) => Term tyname name uni fun ann -> m (Term tyname name uni fun ann) Source #
Rename a Term
in the RenameM
monad.
renameProgramM :: (HasUniques (Program tyname name uni fun ann), MonadQuote m, MonadReader ScopedRenaming m) => Program tyname name uni fun ann -> m (Program tyname name uni fun ann) Source #
Rename a Program
in the RenameM
monad.