   findMatchingDefinitionsOnType type, definitions
 
 findMatchingDefinitionsOnType = (type, definitions) ->
-  setToArray definitions
+  ctx = new Context
+  console.log type, type.type.TypeConstr
+  typesUnify = (def) ->
+    not isFailed mostGeneralUnifier (freshInstance ctx, def.type).type, type.type
+  [typed, notTyped] = partitionMap typesUnify, definitions
+  # allDefs = join (setToArray typed), (setToArray notTyped)
+  allDefs = concatMaps typed, notTyped # TODO: don't use object key ordering for ordering
+  values mapMap (__ prettyPrint, _type), allDefs
 
 # API
 

  catch e
    return "#{type}"

printType = (type) ->
  if type instanceof TypeVariable
    "#{type.name}"
  else if type instanceof QuantifiedVar
    "#{type.var}"
  else if type instanceof TypeConstr
    "#{type.name}"
  else if type instanceof TypeApp
    flattenType collectArgs type
  else if type instanceof ForAll
    "(∀ #{printType type.type})"
  else if type instanceof ClassConstraint
    "(#{type.className} #{(map printType, type.types.types).join ' '})"
  else if type instanceof Constrained
    "(: #{(map printType, join [type.type], type.constraints).join ' '})"
  else if type instanceof TempType
    "(. #{printType type.type})"
  else if Array.isArray type
    "\"#{listOf type}\""

      expression.tea = substitute ctx.substitution, expression.tea
    return
  return

# end of API

