       (concatMaps requires, acc),
       (subtractMaps requires, acc)
     concatMaps collected, acc
+
+requiresFor = (name) ->
+  compiled = lookupInMap moduleGraph, name
+  if not compiled
+    console.error "#{name} module not found"
+    newMap()
+  else
+    compiled.requires
 
 findMatchingDefinitions = (moduleName, reference) ->
   {declared: {savedScopes}} = lookupCompiledModule moduleName

    compilationFn = (topLevelExpressionInModule importsFor moduleDependencies moduleName)
    {js} = compileCtxAstToJs compilationFn, ctx, expression
    (finalizeTypes ctx, expression)
    js: library + immutable + (listOfLines map lookupJs, modules) + '\n;' + js
    ast: ast
    errors: checkTypes ctx


    if not lookupCompiledModule requiredModuleName
      return request: requiredModuleName
  replaceOrAddToMap moduleGraph, moduleName, requires: requiredMap
  toInject = requiresFor moduleName
  ctx = injectedContext toInject
  defaultImports = (subtractSets (newSetWith 'Prelude'), (newSetWith moduleName))
  compilationFn = (topLevelModule moduleName, importsFor defaultImports)
