mirror of
https://github.com/github/semantic.git
synced 2024-11-28 01:47:01 +03:00
Move MonadEnv into its own module.
This commit is contained in:
parent
609b1a1786
commit
9f5a5e0469
@ -23,6 +23,7 @@ library
|
||||
, Abstract.Interpreter.Caching
|
||||
, Abstract.Interpreter.Dead
|
||||
, Abstract.Interpreter.Tracing
|
||||
, Abstract.Monad.Env
|
||||
, Abstract.Store
|
||||
, Abstract.Type
|
||||
, Abstract.Value
|
||||
|
@ -3,8 +3,6 @@ module Abstract.Environment where
|
||||
|
||||
import Abstract.Address
|
||||
import Abstract.FreeVariables
|
||||
import Control.Monad.Effect
|
||||
import Control.Monad.Effect.Reader
|
||||
import Data.Functor.Classes
|
||||
import Data.Functor.Classes.Show.Generic
|
||||
import qualified Data.Map as Map
|
||||
@ -27,15 +25,6 @@ envRoots :: (Ord l, Foldable t) => Environment l a -> t Name -> Set.Set (Address
|
||||
envRoots env = foldr ((<>) . maybe mempty point . flip envLookup env) mempty
|
||||
|
||||
|
||||
class Monad m => MonadEnv l value m where
|
||||
askEnv :: m (Environment l value)
|
||||
localEnv :: (Environment l value -> Environment l value) -> m b -> m b
|
||||
|
||||
instance (Reader (Environment l value) :< fs) => MonadEnv l value (Eff fs) where
|
||||
askEnv = ask
|
||||
localEnv = local
|
||||
|
||||
|
||||
-- Instances
|
||||
|
||||
instance Eq2 Environment where
|
||||
|
@ -7,6 +7,7 @@ module Abstract.Eval
|
||||
|
||||
import Abstract.Environment
|
||||
import Abstract.FreeVariables
|
||||
import Abstract.Monad.Env
|
||||
import Abstract.Store
|
||||
import Abstract.Value
|
||||
import Control.Monad.Effect
|
||||
|
@ -4,6 +4,7 @@ module Abstract.Interpreter where
|
||||
import Abstract.Environment
|
||||
import Abstract.Eval
|
||||
import Abstract.FreeVariables
|
||||
import Abstract.Monad.Env
|
||||
import Abstract.Store
|
||||
import Abstract.Type
|
||||
import Abstract.Value
|
||||
|
@ -6,6 +6,7 @@ import Abstract.Environment
|
||||
import Abstract.Eval
|
||||
import Abstract.FreeVariables
|
||||
import Abstract.Interpreter
|
||||
import Abstract.Monad.Env
|
||||
import Abstract.Store
|
||||
import Abstract.Type
|
||||
import Abstract.Value
|
||||
|
@ -2,8 +2,8 @@
|
||||
module Abstract.Interpreter.Tracing where
|
||||
|
||||
import Abstract.Configuration
|
||||
import Abstract.Environment
|
||||
import Abstract.Eval
|
||||
import Abstract.Monad.Env
|
||||
import Abstract.FreeVariables
|
||||
import Abstract.Interpreter
|
||||
import Abstract.Store
|
||||
|
14
src/Abstract/Monad/Env.hs
Normal file
14
src/Abstract/Monad/Env.hs
Normal file
@ -0,0 +1,14 @@
|
||||
{-# LANGUAGE MultiParamTypeClasses, TypeOperators, UndecidableInstances #-}
|
||||
module Abstract.Monad.Env where
|
||||
|
||||
import Abstract.Environment
|
||||
import Control.Monad.Effect
|
||||
import Control.Monad.Effect.Reader
|
||||
|
||||
class Monad m => MonadEnv l value m where
|
||||
askEnv :: m (Environment l value)
|
||||
localEnv :: (Environment l value -> Environment l value) -> m b -> m b
|
||||
|
||||
instance (Reader (Environment l value) :< fs) => MonadEnv l value (Eff fs) where
|
||||
askEnv = ask
|
||||
localEnv = local
|
@ -2,10 +2,11 @@
|
||||
module Data.Syntax where
|
||||
|
||||
import Abstract.Eval
|
||||
import Abstract.Value (LocationFor, AbstractValue(..))
|
||||
import Abstract.FreeVariables
|
||||
import Abstract.Monad.Env
|
||||
import Abstract.Environment
|
||||
import Abstract.Store
|
||||
import Abstract.Value (LocationFor, AbstractValue(..))
|
||||
import Control.Monad.Effect
|
||||
import Algorithm hiding (Empty)
|
||||
import Control.Applicative
|
||||
|
@ -3,6 +3,7 @@ module Data.Syntax.Declaration where
|
||||
|
||||
import Abstract.Environment
|
||||
import Abstract.Eval
|
||||
import Abstract.Monad.Env
|
||||
import Abstract.Store
|
||||
import Abstract.FreeVariables
|
||||
import Abstract.Type hiding (Type)
|
||||
|
@ -1,9 +1,10 @@
|
||||
{-# LANGUAGE DeriveAnyClass, MultiParamTypeClasses, ScopedTypeVariables, UndecidableInstances #-}
|
||||
module Data.Syntax.Expression where
|
||||
|
||||
import Abstract.Environment
|
||||
import Abstract.Eval
|
||||
import Abstract.Store
|
||||
import Abstract.Environment
|
||||
import Abstract.Monad.Env
|
||||
import Abstract.Value (Value, Closure(..))
|
||||
import Abstract.Type as Type
|
||||
import Abstract.FreeVariables
|
||||
|
@ -1,9 +1,10 @@
|
||||
{-# LANGUAGE DeriveAnyClass, MultiParamTypeClasses, TypeApplications, ScopedTypeVariables, UndecidableInstances #-}
|
||||
module Data.Syntax.Statement where
|
||||
|
||||
import Abstract.Environment
|
||||
import Abstract.Eval
|
||||
import Abstract.FreeVariables
|
||||
import Abstract.Environment
|
||||
import Abstract.Monad.Env
|
||||
import Abstract.Store
|
||||
import Abstract.Value
|
||||
import Algorithm
|
||||
|
Loading…
Reference in New Issue
Block a user