1
1
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:
Rob Rix 2017-11-30 17:43:30 -05:00
parent e938875a93
commit 2df600835f
3 changed files with 21 additions and 16 deletions

View File

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

View File

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

View 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')