1
1
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:
Rob Rix 2017-11-30 15:44:58 -05:00
parent 609b1a1786
commit 9f5a5e0469
11 changed files with 26 additions and 15 deletions

View File

@ -23,6 +23,7 @@ library
, Abstract.Interpreter.Caching
, Abstract.Interpreter.Dead
, Abstract.Interpreter.Tracing
, Abstract.Monad.Env
, Abstract.Store
, Abstract.Type
, Abstract.Value

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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
View 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

View File

@ -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

View File

@ -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)

View File

@ -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

View File

@ -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