1
1
mirror of https://github.com/github/semantic.git synced 2024-12-29 18:06:14 +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 <$ modify (Map.insertWith (<>) term (Set.singleton (result :: a)))
runHeap :: name -> StateC (Heap name a) m b -> m (Heap name a, b)
runHeap addr m = runState (Map.singleton addr Set.empty) m
runHeap :: StateC (Heap name a) m b -> m (Heap name a, b)
runHeap m = runState Map.empty m
-- | Fold a collection by mapping each element onto an 'Alternative' action.
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
= run
. runFresh
. runHeap "__semantic_root"
. runHeap
. traverse runFile
runFile :: ( Carrier sig m

View File

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

View File

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