   {request, ast, ir, js} = compileCtxAstToJs compilationFn, ctx, (astFromSource "(#{source})", -1, -1)
   if request
     if not allInjected request, requiredMap
-      return compileTopLevel source, moduleName, request
+      return compileModuleTopLevel source, moduleName, request
     else
       {js} = compileCtxIrToJs ctx, ir
   errors = checkTypes ctx

  # types: typeEnumaration ctx
  errors: errors

compileModule = (moduleName = '@unnamed') ->
  js: library + immutable + (listOfLines map lookupJs, (setToArray runtimeDependencies moduleName))

compileExpression = (source, moduleName = '@unnamed') ->
  ast = (astFromSource "(#{source})", -1, -1)
  if _empty _validTerms ast
    {
      ast: ast
      js: ''
    }
  else
    {modules, ctx} = contextWithDependencies moduleDependencies moduleName
    [expression] = _terms ast
    compilationFn = (topLevelExpressionInModule importsFor moduleDependencies moduleName)
    {js} = compileCtxAstToJs compilationFn, ctx, expression
    errors = checkTypes ctx
    (finalizeTypes ctx, expression)
    js: library + immutable + (listOfLines map lookupJs, (setToArray runtimeDependencies moduleName)) + '\n;' + js
    ast: ast
    errors: errors
    malformed: ctx.isMalformed

expandCall = (moduleName, call) ->
  {modules, ctx} = contextWithDependencies moduleDependencies moduleName

  lookupInMap compiledModules, name


compileModuleTopLevel = (source, moduleName = '@unnamed', requiredMap = newMap()) ->
  addToMap requiredMap, 'Prelude', yes # TODO: Hardcoded prelude dependency
  removeFromMap requiredMap, moduleName
  for requiredModuleName of values requiredMap
