       if instanceContraints
         toNormalize.push instanceContraints...
       else
-        # TODO: propogate this as standard error
-        # throw new Error "no instance found to satisfy #{safePrintType constraint}"
         return error: instanceLookupFailed constraint
       after = subLimit ctx.substitution
       # There was a functional dependency, renormalize

      emptySubstitution()
    else
      unifyFail t1, t2
  else if t1.TypeVariable and kindsEq (kind t1), (kind t2)
    t1.ref.val = t2 #newSubstitution t1.name, t2
    # console.log "attaching", t1.name, t2
    # console.log "attached", (printType t2)
    newSubstitution()
  else if t2.TypeVariable and t2.ref.val
    matchType t1, t2.ref.val
  else if t1.TypeConstr and t2.TypeConstr and t1.name is t2.name
    emptySubstitution()
  else if t1.TypeApp and t2.TypeApp

      s1 = matchType t1.types[0], t2.types[0]
      # We imply functional dependency of the form A a b c | a -> b c
      # s2 = mostGeneralUnifier (new Types (substituteList s1, t1.types[1...])), (new Types t2.types[1...])
      if isFailed s1
        s1
      else
        unifyImpliedParams t1, t2
    else
      emptySubstitution()
  else
    unifyFail t1, t2

# We need to check that the unification succeeds first before performing
# it on the actual types
unifyImpliedParams = (t1, t2) ->
  types1 = new Types t1.types[1...]
  types2 = new Types t2.types[1...]
  makeSub = (types) ->
    mapMap ((kind, name) -> new TypeVariable name, kind, {}), findFree types
  subbed1 = substitute (makeSub types1), types1
  subbed2 = substitute (makeSub types2), types2
  if isFailed (sub = mostGeneralUnifier subbed1, subbed2)
    sub
  else
    mostGeneralUnifier types1, types2


# Used to convert between quantified and not quantified
substitute = (substitution, type) ->
