mirror of
https://github.com/github/semantic.git
synced 2024-12-15 01:51:39 +03:00
Clean up some remaining vestiges of non-empty module tables.
This commit is contained in:
parent
40737635f0
commit
f2da4ed031
@ -47,9 +47,9 @@ keys :: ModuleTable a -> [ModulePath]
|
|||||||
keys = Map.keys . unModuleTable
|
keys = Map.keys . unModuleTable
|
||||||
|
|
||||||
-- | Construct a 'ModuleTable' from a non-empty list of 'Module's.
|
-- | Construct a 'ModuleTable' from a non-empty list of 'Module's.
|
||||||
fromModules :: [Module term] -> ModuleTable (NonEmpty (Module term))
|
fromModules :: [Module term] -> ModuleTable (Module term)
|
||||||
fromModules modules = ModuleTable (Map.fromListWith (<>) (map toEntry modules))
|
fromModules = ModuleTable . Map.fromList . map toEntry
|
||||||
where toEntry m = (modulePath (moduleInfo m), m:|[])
|
where toEntry m = (modulePath (moduleInfo m), m)
|
||||||
|
|
||||||
toPairs :: ModuleTable a -> [(ModulePath, a)]
|
toPairs :: ModuleTable a -> [(ModulePath, a)]
|
||||||
toPairs = Map.toList . unModuleTable
|
toPairs = Map.toList . unModuleTable
|
||||||
|
@ -25,7 +25,7 @@ data PackageInfo = PackageInfo
|
|||||||
-- | A package represents the unit of dependency, i.e. something which can depend upon, or be depended upon by, other packages. Packages have modules and may have entry points from which evaluation can proceed.
|
-- | A package represents the unit of dependency, i.e. something which can depend upon, or be depended upon by, other packages. Packages have modules and may have entry points from which evaluation can proceed.
|
||||||
data Package term = Package
|
data Package term = Package
|
||||||
{ packageInfo :: PackageInfo
|
{ packageInfo :: PackageInfo
|
||||||
, packageModules :: ModuleTable (NonEmpty (Module term))
|
, packageModules :: ModuleTable (Module term)
|
||||||
}
|
}
|
||||||
deriving (Eq, Functor, Ord, Show)
|
deriving (Eq, Functor, Ord, Show)
|
||||||
|
|
||||||
|
@ -157,7 +157,7 @@ runImportGraphToModuleInfos :: ( Declarations term
|
|||||||
-> Package term
|
-> Package term
|
||||||
-> Eff m (Graph ControlFlowVertex)
|
-> Eff m (Graph ControlFlowVertex)
|
||||||
runImportGraphToModuleInfos lang (package :: Package term) = runImportGraph lang package allModuleInfos
|
runImportGraphToModuleInfos lang (package :: Package term) = runImportGraph lang package allModuleInfos
|
||||||
where allModuleInfos info = maybe (vertex (unknownModuleVertex info)) (foldMap (vertex . moduleVertex . moduleInfo)) (ModuleTable.lookup (modulePath info) (packageModules package))
|
where allModuleInfos info = vertex (maybe (unknownModuleVertex info) (moduleVertex . moduleInfo) (ModuleTable.lookup (modulePath info) (packageModules package)))
|
||||||
|
|
||||||
runImportGraphToModules :: ( Declarations term
|
runImportGraphToModules :: ( Declarations term
|
||||||
, Evaluatable (Base term)
|
, Evaluatable (Base term)
|
||||||
@ -173,7 +173,7 @@ runImportGraphToModules :: ( Declarations term
|
|||||||
-> Package term
|
-> Package term
|
||||||
-> Eff m (Graph (Module term))
|
-> Eff m (Graph (Module term))
|
||||||
runImportGraphToModules lang (package :: Package term) = runImportGraph lang package resolveOrLowerBound
|
runImportGraphToModules lang (package :: Package term) = runImportGraph lang package resolveOrLowerBound
|
||||||
where resolveOrLowerBound info = maybe lowerBound (foldMap vertex) (ModuleTable.lookup (modulePath info) (packageModules package))
|
where resolveOrLowerBound info = maybe lowerBound vertex (ModuleTable.lookup (modulePath info) (packageModules package))
|
||||||
|
|
||||||
runImportGraph :: ( Declarations term
|
runImportGraph :: ( Declarations term
|
||||||
, Evaluatable (Base term)
|
, Evaluatable (Base term)
|
||||||
@ -210,7 +210,7 @@ runImportGraph lang (package :: Package term) f
|
|||||||
. raiseHandler (runReader (lowerBound @Span))
|
. raiseHandler (runReader (lowerBound @Span))
|
||||||
. raiseHandler (runState (lowerBound @(ScopeGraph (Hole (Maybe Name) Precise))))
|
. raiseHandler (runState (lowerBound @(ScopeGraph (Hole (Maybe Name) Precise))))
|
||||||
. runAllocator
|
. runAllocator
|
||||||
$ evaluate lang (graphingModuleInfo (runDomainEffects (evalTerm id))) (ModuleTable.toPairs ( packageModules package) >>= toList . snd)
|
$ evaluate lang (graphingModuleInfo (runDomainEffects (evalTerm id))) (snd <$> ModuleTable.toPairs (packageModules package))
|
||||||
|
|
||||||
runHeap :: (Carrier sig m, Effect sig)
|
runHeap :: (Carrier sig m, Effect sig)
|
||||||
=> Evaluator term address value (StateC (Heap address address value) (Eff m)) a
|
=> Evaluator term address value (StateC (Heap address address value) (Eff m)) a
|
||||||
|
@ -92,7 +92,7 @@ repl proxy parser paths = defaultConfig debugOptions >>= \ config -> runM . runD
|
|||||||
. raiseHandler (runReader (packageInfo package))
|
. raiseHandler (runReader (packageInfo package))
|
||||||
. raiseHandler (runState (lowerBound @Span))
|
. raiseHandler (runState (lowerBound @Span))
|
||||||
. raiseHandler (runReader (lowerBound @Span))
|
. raiseHandler (runReader (lowerBound @Span))
|
||||||
$ evaluate proxy (runDomainEffects (evalTerm (withTermSpans . step (fmap (\ (x:|_) -> moduleBody x) <$> ModuleTable.toPairs (packageModules (fst <$> package)))))) modules
|
$ evaluate proxy (runDomainEffects (evalTerm (withTermSpans . step (fmap moduleBody <$> ModuleTable.toPairs (packageModules (fst <$> package)))))) modules
|
||||||
|
|
||||||
-- TODO: REPL for typechecking/abstract semantics
|
-- TODO: REPL for typechecking/abstract semantics
|
||||||
-- TODO: drive the flow from within the REPL instead of from without
|
-- TODO: drive the flow from within the REPL instead of from without
|
||||||
|
Loading…
Reference in New Issue
Block a user