Copyright | (C) 2020-2021 QBayLogic B.V. |
---|---|
License | BSD2 (see the file LICENSE) |
Maintainer | QBayLogic B.V. <devops@qbaylogic.com> |
Safe Haskell | None |
Language | Haskell2010 |
The monad for partial evaluation, and its API. This should contain all auxiliary functions needed to define new evaluator implementations. This module is only needed to define new evaluators, for calling an existing evaluator see Clash.Core.PartialEval.
Synopsis
- data Eval a
- runEval :: GlobalEnv -> LocalEnv -> Eval a -> IO (a, GlobalEnv)
- getLocalEnv :: Eval LocalEnv
- setLocalEnv :: LocalEnv -> Eval a -> Eval a
- modifyLocalEnv :: (LocalEnv -> LocalEnv) -> Eval a -> Eval a
- getGlobalEnv :: Eval GlobalEnv
- modifyGlobalEnv :: (GlobalEnv -> GlobalEnv) -> Eval ()
- getContext :: Eval Id
- withContext :: Id -> Eval a -> Eval a
- getTvSubst :: Eval Subst
- findTyVar :: TyVar -> Eval (Maybe Type)
- withTyVar :: TyVar -> Type -> Eval a -> Eval a
- withTyVars :: [(TyVar, Type)] -> Eval a -> Eval a
- findId :: Id -> Eval (Maybe Value)
- withId :: Id -> Value -> Eval a -> Eval a
- withIds :: [(Id, Value)] -> Eval a -> Eval a
- withoutId :: Id -> Eval a -> Eval a
- findBinding :: Id -> Eval (Maybe (Binding Value))
- replaceBinding :: Binding Value -> Eval ()
- getRef :: Int -> Eval Value
- setRef :: Int -> Value -> Eval ()
- isKeepingLifted :: Eval Bool
- keepLifted :: Eval a -> Eval a
- getFuel :: Eval Word
- withFuel :: Eval a -> Eval a
- preserveFuel :: Eval a -> Eval a
- getTyConMap :: Eval TyConMap
- getInScope :: Eval InScopeSet
- getUniqueId :: OccName -> Type -> Eval Id
- getUniqueTyVar :: OccName -> Kind -> Eval TyVar
- workFreeValue :: Value -> Eval Bool
Partial Evaluation Monad
The monad of partial evaluation. The inner monad is IO, as primitive evaluation can attempt to evaluate IO actions.
Instances
Monad Eval Source # | |
Functor Eval Source # | |
MonadFail Eval Source # | |
Defined in Clash.Core.PartialEval.Monad | |
Applicative Eval Source # | |
Alternative Eval Source # | |
MonadIO Eval Source # | |
Defined in Clash.Core.PartialEval.Monad | |
MonadThrow Eval Source # | |
Defined in Clash.Core.PartialEval.Monad | |
MonadCatch Eval Source # | |
MonadMask Eval Source # | |
MonadReader LocalEnv Eval Source # | |
MonadState GlobalEnv Eval Source # | |
runEval :: GlobalEnv -> LocalEnv -> Eval a -> IO (a, GlobalEnv) Source #
Evaluate an action in the partial evaluator, returning the result, and the final state of the global environment.
Local and Global Environments
Evaluation Context
getContext :: Eval Id Source #
Local Type Bindings
getTvSubst :: Eval Subst Source #
Local Term Bindings
Global Term Bindings
IO Heap Bindings
Lifted Data Constructors
keepLifted :: Eval a -> Eval a Source #
Fuel
preserveFuel :: Eval a -> Eval a Source #