mirror of
https://github.com/github/semantic.git
synced 2024-12-29 18:06:14 +03:00
Define a single, universal instance of MonadHeap.
This commit is contained in:
parent
b109fcd51f
commit
7d39812ea3
@ -7,7 +7,6 @@ import Prologue
|
||||
newtype BadAddresses m (effects :: [* -> *]) a = BadAddresses (m effects a)
|
||||
deriving (Alternative, Applicative, Functor, Effectful, Monad, MonadFail, MonadFresh)
|
||||
|
||||
deriving instance MonadHeap location value effects m => MonadHeap location value effects (BadAddresses m)
|
||||
deriving instance MonadModuleTable location term value effects m => MonadModuleTable location term value effects (BadAddresses m)
|
||||
deriving instance MonadEvaluator location term value effects m => MonadEvaluator location term value effects (BadAddresses m)
|
||||
|
||||
|
@ -8,7 +8,6 @@ import Prologue
|
||||
newtype BadModuleResolutions m (effects :: [* -> *]) a = BadModuleResolutions (m effects a)
|
||||
deriving (Alternative, Applicative, Functor, Effectful, Monad, MonadFail, MonadFresh)
|
||||
|
||||
deriving instance MonadHeap location value effects m => MonadHeap location value effects (BadModuleResolutions m)
|
||||
deriving instance MonadModuleTable location term value effects m => MonadModuleTable location term value effects (BadModuleResolutions m)
|
||||
deriving instance MonadEvaluator location term value effects m => MonadEvaluator location term value effects (BadModuleResolutions m)
|
||||
|
||||
|
@ -10,7 +10,6 @@ import Data.ByteString.Char8 (pack)
|
||||
newtype BadValues m (effects :: [* -> *]) a = BadValues (m effects a)
|
||||
deriving (Alternative, Applicative, Functor, Effectful, Monad, MonadFail, MonadFresh)
|
||||
|
||||
deriving instance MonadHeap location value effects m => MonadHeap location value effects (BadValues m)
|
||||
deriving instance MonadModuleTable location term value effects m => MonadModuleTable location term value effects (BadValues m)
|
||||
deriving instance MonadEvaluator location term value effects m => MonadEvaluator location term value effects (BadValues m)
|
||||
|
||||
|
@ -11,7 +11,6 @@ import Prologue
|
||||
newtype BadVariables m (effects :: [* -> *]) a = BadVariables (m effects a)
|
||||
deriving (Alternative, Applicative, Functor, Effectful, Monad, MonadFail, MonadFresh)
|
||||
|
||||
deriving instance MonadHeap location value effects m => MonadHeap location value effects (BadVariables m)
|
||||
deriving instance MonadModuleTable location term value effects m => MonadModuleTable location term value effects (BadVariables m)
|
||||
deriving instance MonadEvaluator location term value effects m => MonadEvaluator location term value effects (BadVariables m)
|
||||
|
||||
|
@ -22,7 +22,6 @@ type CachingEffects location term value effects
|
||||
newtype Caching m (effects :: [* -> *]) a = Caching (m effects a)
|
||||
deriving (Alternative, Applicative, Functor, Effectful, Monad, MonadFail, MonadFresh)
|
||||
|
||||
deriving instance MonadHeap location value effects m => MonadHeap location value effects (Caching m)
|
||||
deriving instance MonadModuleTable location term value effects m => MonadModuleTable location term value effects (Caching m)
|
||||
deriving instance MonadEvaluator location term value effects m => MonadEvaluator location term value effects (Caching m)
|
||||
|
||||
|
@ -13,7 +13,6 @@ import Prologue
|
||||
newtype Collecting m (effects :: [* -> *]) a = Collecting (m effects a)
|
||||
deriving (Alternative, Applicative, Functor, Effectful, Monad, MonadFail, MonadFresh)
|
||||
|
||||
deriving instance MonadHeap location value effects m => MonadHeap location value effects (Collecting m)
|
||||
deriving instance MonadModuleTable location term value effects m => MonadModuleTable location term value effects (Collecting m)
|
||||
|
||||
instance ( Effectful m
|
||||
|
@ -13,7 +13,6 @@ import Prologue
|
||||
newtype DeadCode m (effects :: [* -> *]) a = DeadCode (m effects a)
|
||||
deriving (Alternative, Applicative, Functor, Effectful, Monad, MonadFail, MonadFresh)
|
||||
|
||||
deriving instance MonadHeap location value effects m => MonadHeap location value effects (DeadCode m)
|
||||
deriving instance MonadModuleTable location term value effects m => MonadModuleTable location term value effects (DeadCode m)
|
||||
deriving instance MonadEvaluator location term value effects m => MonadEvaluator location term value effects (DeadCode m)
|
||||
|
||||
|
@ -48,11 +48,6 @@ view :: Member (State (EvaluatorState location term value)) effects => Getting a
|
||||
view lens = raise (gets (^. lens))
|
||||
|
||||
|
||||
instance Member (State (EvaluatorState location term value)) effects
|
||||
=> MonadHeap location value effects (Evaluating location term value) where
|
||||
getHeap = view _heap
|
||||
putHeap = (_heap .=)
|
||||
|
||||
instance Members '[ Reader (ModuleTable [Module term])
|
||||
, State (EvaluatorState location term value)
|
||||
, Reader (SomeOrigin term)
|
||||
|
@ -57,7 +57,6 @@ style = (defaultStyle vertexName)
|
||||
newtype ImportGraphing m (effects :: [* -> *]) a = ImportGraphing (m effects a)
|
||||
deriving (Alternative, Applicative, Functor, Effectful, Monad, MonadFail, MonadFresh)
|
||||
|
||||
deriving instance MonadHeap location value effects m => MonadHeap location value effects (ImportGraphing m)
|
||||
deriving instance MonadModuleTable location term value effects m => MonadModuleTable location term value effects (ImportGraphing m)
|
||||
deriving instance MonadEvaluator location term value effects m => MonadEvaluator location term value effects (ImportGraphing m)
|
||||
|
||||
|
@ -17,7 +17,6 @@ import Prologue
|
||||
newtype Quietly m (effects :: [* -> *]) a = Quietly (m effects a)
|
||||
deriving (Alternative, Applicative, Functor, Effectful, Monad, MonadFail, MonadFresh)
|
||||
|
||||
deriving instance MonadHeap location value effects m => MonadHeap location value effects (Quietly m)
|
||||
deriving instance MonadModuleTable location term value effects m => MonadModuleTable location term value effects (Quietly m)
|
||||
deriving instance MonadEvaluator location term value effects m => MonadEvaluator location term value effects (Quietly m)
|
||||
|
||||
|
@ -16,7 +16,6 @@ import Prologue
|
||||
newtype Tracing (trace :: * -> *) m (effects :: [* -> *]) a = Tracing (m effects a)
|
||||
deriving (Alternative, Applicative, Functor, Effectful, Monad, MonadFail, MonadFresh)
|
||||
|
||||
deriving instance MonadHeap location value effects m => MonadHeap location value effects (Tracing trace m)
|
||||
deriving instance MonadModuleTable location term value effects m => MonadModuleTable location term value effects (Tracing trace m)
|
||||
deriving instance MonadEvaluator location term value effects m => MonadEvaluator location term value effects (Tracing trace m)
|
||||
|
||||
|
@ -64,7 +64,6 @@ class ( Effectful m
|
||||
, Member (State (EvaluatorState location term value)) effects
|
||||
, Monad (m effects)
|
||||
, MonadModuleTable location term value effects m
|
||||
, MonadHeap location value effects m
|
||||
)
|
||||
=> MonadEvaluator location term value (effects :: [* -> *]) m | m effects -> location term value where
|
||||
-- | Get the current 'Configuration' with a passed-in term.
|
||||
@ -211,6 +210,10 @@ class Monad (m effects) => MonadHeap location value (effects :: [* -> *]) m | m
|
||||
-- | Set the heap.
|
||||
putHeap :: Heap location value -> m effects ()
|
||||
|
||||
instance (Monad (m effects), MonadEvaluator location term value effects m) => MonadHeap location value effects m where
|
||||
getHeap = view _heap
|
||||
putHeap = (_heap .=)
|
||||
|
||||
-- | Update the heap.
|
||||
modifyHeap :: MonadHeap location value effects m => (Heap location value -> Heap location value) -> m effects ()
|
||||
modifyHeap f = do
|
||||
|
Loading…
Reference in New Issue
Block a user