mirror of
https://github.com/github/semantic.git
synced 2024-11-24 08:54:07 +03:00
Move MonadGC into its own module.
This commit is contained in:
parent
e938875a93
commit
2df600835f
@ -39,6 +39,7 @@ library
|
||||
, Control.Effect
|
||||
, Control.Monad.Effect.Env
|
||||
, Control.Monad.Effect.Fresh
|
||||
, Control.Monad.Effect.GC
|
||||
-- General datatype definitions & generic algorithms
|
||||
, Data.Algebra
|
||||
, Data.Align.Generic
|
||||
|
@ -7,16 +7,12 @@ module Abstract.Eval
|
||||
|
||||
import Abstract.Environment
|
||||
import Abstract.FreeVariables
|
||||
import Abstract.Store
|
||||
import Abstract.Value
|
||||
import Control.Monad.Effect
|
||||
import Control.Monad.Effect.Env
|
||||
import Control.Monad.Effect.Reader
|
||||
import Control.Monad.Effect.GC
|
||||
import Control.Monad.Fail
|
||||
import Data.Functor.Classes
|
||||
import Data.Proxy
|
||||
import Data.Semigroup
|
||||
import qualified Data.Set as Set
|
||||
import Data.Term
|
||||
import Data.Union
|
||||
import Prelude hiding (fail)
|
||||
@ -35,17 +31,6 @@ instance (Monad m, Eval t v m s) => Eval t v m (TermF s a) where
|
||||
eval ev yield In{..} = eval ev yield termFOut
|
||||
|
||||
|
||||
class Monad m => MonadGC a m where
|
||||
askRoots :: m (Set.Set (Address (LocationFor a) a))
|
||||
|
||||
extraRoots :: Set.Set (Address (LocationFor a) a) -> m b -> m b
|
||||
|
||||
instance (Ord (LocationFor a), Reader (Set.Set (Address (LocationFor a) a)) :< fs) => MonadGC a (Eff fs) where
|
||||
askRoots = ask :: Eff fs (Set.Set (Address (LocationFor a) a))
|
||||
|
||||
extraRoots roots' = local (<> roots')
|
||||
|
||||
|
||||
instance ( Monad m
|
||||
, Ord (LocationFor v)
|
||||
, MonadGC v m
|
||||
|
19
src/Control/Monad/Effect/GC.hs
Normal file
19
src/Control/Monad/Effect/GC.hs
Normal file
@ -0,0 +1,19 @@
|
||||
{-# LANGUAGE MultiParamTypeClasses, ScopedTypeVariables, TypeOperators, UndecidableInstances #-}
|
||||
module Control.Monad.Effect.GC where
|
||||
|
||||
import Abstract.Address
|
||||
import Abstract.Value
|
||||
import Control.Monad.Effect
|
||||
import Control.Monad.Effect.Reader
|
||||
import Data.Semigroup ((<>))
|
||||
import Data.Set (Set)
|
||||
|
||||
class Monad m => MonadGC a m where
|
||||
askRoots :: m (Set (Address (LocationFor a) a))
|
||||
|
||||
extraRoots :: Set (Address (LocationFor a) a) -> m b -> m b
|
||||
|
||||
instance (Ord (LocationFor a), Reader (Set (Address (LocationFor a) a)) :< fs) => MonadGC a (Eff fs) where
|
||||
askRoots = ask :: Eff fs (Set (Address (LocationFor a) a))
|
||||
|
||||
extraRoots roots' = local (<> roots')
|
Loading…
Reference in New Issue
Block a user