       [t2from, t2to] = t2
       unifyWith subs, [[t1from, t2from], [t1to, t2to]].concat rest
     else
-      throw new Error "Types #{t1}, #{t2} could not be unified"
+      throw new TypeError "Types #{t1}, #{t2} could not be unified", [t1, t2]
 
 subPairs = (subs, pairs) ->
   for [t1, t2] in pairs

        [s1, nextIndex, expression]

      # Call
      else if (Array.isArray expression) and expression.length > 2
        [op..., arg] = inside expression
        [s, nextIndex, tea] = inferCall context, [op, arg], nameIndex
        expression.tea = tea
        [s, nextIndex, expression]

inferCall = (context, pair, nameIndex) ->
  [ops, arg] = pair

freshName = (nameIndex) ->
  suffix = if nameIndex > 25 then nameIndex // 25 else ''
  String.fromCharCode 97 + nameIndex % 25

ignoreTypeErrors = (fn) ->
  try
    ret = fn()
  catch e
    unless e instanceof TypeError
      throw e

class TypeError extends Error
  # required for instanceof to work
  constructor: (@message, @data) -> super @message

# mycroft = (context, node, environment) ->
#   if node.label is 'numerical'
