   sub.start = name
   sub
 
+isFailed = (sub) ->
+  sub.fails.length > 0
+
 substituionFail = (failure) ->
   sub = emptySubstitution()
   sub.fails.push failure

# Primitive type checking for now
checkTypes = (ctx) ->
  # failed = mapToArray filterMap ((name) -> name is 'could not unify'), ctx.substitution
  if _notEmpty (failed = ctx.substitution.fails)
    failed

lookupJs = (moduleName) ->
  js = (lookupCompiledModule moduleName)?.js

  {declared: {savedScopes}} = lookupCompiledModule moduleName
  {ctx} = contextWithDependencies moduleName
  {scope, type} = reference
  return [] unless scope?
  definitions = concatMaps (while scope isnt 0
    found = savedScopes[scope]
    scope = found.parent
