1
1
mirror of https://github.com/github/semantic.git synced 2025-01-06 06:46:07 +03:00

Define a MonadOrigin instance for Evaluating.

This commit is contained in:
Rob Rix 2018-03-29 23:28:32 -04:00
parent a0667d0414
commit 424cac7ab2

View File

@ -14,6 +14,7 @@ import Data.Abstract.Exports
import Data.Abstract.Heap import Data.Abstract.Heap
import Data.Abstract.Module import Data.Abstract.Module
import Data.Abstract.ModuleTable import Data.Abstract.ModuleTable
import Data.Abstract.Origin
import qualified Data.IntMap as IntMap import qualified Data.IntMap as IntMap
import Lens.Micro import Lens.Micro
import Prelude hiding (fail) import Prelude hiding (fail)
@ -37,6 +38,7 @@ type EvaluatingEffects location term value
, Fail -- Failure with an error message , Fail -- Failure with an error message
, Fresh -- For allocating new addresses and/or type variables. , Fresh -- For allocating new addresses and/or type variables.
, Reader [Module term] -- The stack of currently-evaluating modules. , Reader [Module term] -- The stack of currently-evaluating modules.
, Reader Origin -- The current terms origin.
, Reader (ModuleTable [Module term]) -- Cache of unevaluated modules , Reader (ModuleTable [Module term]) -- Cache of unevaluated modules
, Reader (Environment location value) -- Default environment used as a fallback in lookupEnv , Reader (Environment location value) -- Default environment used as a fallback in lookupEnv
, State (EvaluatingState location term value) -- Environment, heap, modules, exports, and jumps. , State (EvaluatingState location term value) -- Environment, heap, modules, exports, and jumps.
@ -139,6 +141,10 @@ instance Members (EvaluatingEffects location term value) effects
askModuleStack = raise ask askModuleStack = raise ask
instance Member (Reader Origin) effects
=> MonadOrigin (Evaluating location term value effects) where
askOrigin = raise ask
instance ( Members (EvaluatingEffects location term value) effects instance ( Members (EvaluatingEffects location term value) effects
, MonadValue location value (Evaluating location term value effects) , MonadValue location value (Evaluating location term value effects)
) )