   ast = (astFromSource "(#{source})", -1, -1)
   [expression] = _terms ast
   {js} = compileCtxAstToJs topLevelExpression, ctx, expression
-  checkTypes ctx
   (attachPrintedTypes ctx, expression)
   js: library + immutable + (listOfLines map lookupJs, setToArray toInject) + js
   ast: ast
+  errors: checkTypes ctx
 
 # Primitive type checking for now
 checkTypes = (ctx) ->
   # failed = mapToArray filterMap ((name) -> name is 'could not unify'), ctx.substitution
   if _notEmpty (failed = ctx.substitution.fails)
-    throw new Error failed[0]
+    failed
 
 lookupJs = (moduleName) ->
   js = (lookupInMap compiledModules, moduleName)?.js


constantLabeling = (atom) ->
  {symbol} = atom
  labelMapping atom,
    ['numerical', /^~?\d+/.test symbol]
    ['label', isLabel atom]
    ['string', /^"/.test symbol]
    ['char', /^\\/.test symbol]
    ['regex', /^\/[^\s\/]/.test symbol]
    ['const', /^[A-Z][^\s\.]*$/.test symbol] # TODO: instead label based on context
    ['paren', symbol in ['(', ')']]
    ['bracket', symbol in ['[', ']']]
    ['brace', symbol in ['{', '}']]
    ['whitespace', /^\s+$/.test symbol]

noWhitespace = (tokens) ->
  tokens.filter (token) -> token.label not in ['whitespace', 'indent']

labelMapping = (word, rules...) ->
  for [label, cond] in rules when cond
    word.label = label
    return word
  word

  Array.isArray expression

isLabel = (atom) ->
  /[^\\]:$/.test atom.symbol

isCapital = (atom) ->
  /[A-Z]/.test atom.symbol
