mirror of
https://github.com/github/semantic.git
synced 2024-12-23 23:11:50 +03:00
Move the unevaluated module table and load stack accessors into the module table effects module.
This commit is contained in:
parent
eabb3b79a1
commit
6557859772
@ -3,10 +3,14 @@ module Control.Abstract.ModuleTable
|
||||
, getModuleTable
|
||||
, putModuleTable
|
||||
, modifyModuleTable
|
||||
, askModuleTable
|
||||
, askLoadStack
|
||||
, localLoadStack
|
||||
) where
|
||||
|
||||
import Control.Abstract.Evaluator
|
||||
import Data.Abstract.Environment
|
||||
import Data.Abstract.Module
|
||||
import Data.Abstract.ModuleTable
|
||||
import Prologue
|
||||
|
||||
@ -21,3 +25,18 @@ putModuleTable = raise . put
|
||||
-- | Update the evaluated module table.
|
||||
modifyModuleTable :: Member (State (ModuleTable (Environment location value, value))) effects => (ModuleTable (Environment location value, value) -> ModuleTable (Environment location value, value)) -> Evaluator location term value effects ()
|
||||
modifyModuleTable = raise . modify'
|
||||
|
||||
|
||||
-- | Retrieve the table of unevaluated modules.
|
||||
askModuleTable :: Member (Reader (ModuleTable [Module term])) effects
|
||||
=> Evaluator location term value effects (ModuleTable [Module term])
|
||||
askModuleTable = raise ask
|
||||
|
||||
|
||||
-- | Retrieve the module load stack
|
||||
askLoadStack :: Member (Reader LoadStack) effects => Evaluator location term value effects LoadStack
|
||||
askLoadStack = raise ask
|
||||
|
||||
-- | Locally update the module load stack.
|
||||
localLoadStack :: Member (Reader LoadStack) effects => (LoadStack -> LoadStack) -> Evaluator location term value effects a -> Evaluator location term value effects a
|
||||
localLoadStack = raiseHandler . local
|
||||
|
@ -230,19 +230,6 @@ instance Evaluatable [] where
|
||||
-- 'nonEmpty' and 'foldMap1' enable us to return the last statement’s result instead of 'unit' for non-empty lists.
|
||||
eval = maybe unit (runApp . foldMap1 (App . subtermValue)) . nonEmpty
|
||||
|
||||
-- | Retrieve the table of unevaluated modules.
|
||||
askModuleTable :: Member (Reader (ModuleTable [Module term])) effects
|
||||
=> Evaluator location term value effects (ModuleTable [Module term])
|
||||
askModuleTable = raise ask
|
||||
|
||||
-- | Retrieve the module load stack
|
||||
askLoadStack :: Member (Reader LoadStack) effects => Evaluator location term value effects LoadStack
|
||||
askLoadStack = raise ask
|
||||
|
||||
-- | Locally update the module load stack.
|
||||
localLoadStack :: Member (Reader LoadStack) effects => (LoadStack -> LoadStack) -> Evaluator location term value effects a -> Evaluator location term value effects a
|
||||
localLoadStack = raiseHandler . local
|
||||
|
||||
|
||||
-- Resolve a list of module paths to a possible module table entry.
|
||||
resolve :: Member (Reader (ModuleTable [Module term])) effects
|
||||
|
Loading…
Reference in New Issue
Block a user