1
1
mirror of https://github.com/github/semantic.git synced 2024-11-28 01:47:01 +03:00

Don’t allocate a pointless heap cell.

This commit is contained in:
Rob Rix 2019-07-25 13:28:02 -04:00
parent b8f7bb06db
commit cb5b0fb2c4
No known key found for this signature in database
GPG Key ID: F188A01508EA1CF7
4 changed files with 5 additions and 5 deletions

View File

@ -65,8 +65,8 @@ cacheTerm eval term = do
result <- eval term result <- eval term
result <$ modify (Map.insertWith (<>) term (Set.singleton (result :: a))) result <$ modify (Map.insertWith (<>) term (Set.singleton (result :: a)))
runHeap :: name -> StateC (Heap name a) m b -> m (Heap name a, b) runHeap :: StateC (Heap name a) m b -> m (Heap name a, b)
runHeap addr m = runState (Map.singleton addr Set.empty) m runHeap m = runState Map.empty m
-- | Fold a collection by mapping each element onto an 'Alternative' action. -- | Fold a collection by mapping each element onto an 'Alternative' action.
foldMapA :: (Alternative m, Foldable t) => (b -> m a) -> t b -> m a foldMapA :: (Alternative m, Foldable t) => (b -> m a) -> t b -> m a

View File

@ -52,7 +52,7 @@ importGraph :: [File (Term Core.Core User)] -> (Heap User Value, [File (Either (
importGraph importGraph
= run = run
. runFresh . runFresh
. runHeap "__semantic_root" . runHeap
. traverse runFile . traverse runFile
runFile :: ( Carrier sig m runFile :: ( Carrier sig m

View File

@ -58,7 +58,7 @@ scopeGraph :: [File (Term Core.Core User)] -> (Heap User Value, [File (Either (L
scopeGraph scopeGraph
= run = run
. runFresh . runFresh
. runHeap "__semantic_root" . runHeap
. traverse runFile . traverse runFile
runFile runFile

View File

@ -90,7 +90,7 @@ typecheckingFlowInsensitive :: [File (Term Core.Core User)] -> (Heap User (Term
typecheckingFlowInsensitive typecheckingFlowInsensitive
= run = run
. runFresh . runFresh
. runHeap "__semantic_root" . runHeap
. fmap (fmap (fmap (fmap generalize))) . fmap (fmap (fmap (fmap generalize)))
. traverse runFile . traverse runFile