   counter = {}
   classParams = newMap()
   for constraint in reducedConstraints when not isAlreadyParametrized ctx, constraint
-    {className, type} = constraint
-    typeMap = lookupInMap classParams, type.name
+    {className} = constraint
+    names = typeNamesOfNormalized constraint
+    typeMap = nestedLookupInMap classParams, names
     if not typeMap
-      addToMap classParams, type.name, (typeMap = newMap())
+      nestedAddToMap classParams, names, (typeMap = newMap())
     addToMap typeMap, className,
       "_#{className}_#{counter[className] ?= 0; ++counter[className]}"
   ctx.addClassParams classParams

  for k, v of mapB.values when k of mapA.values
    addToMap intersection, k, v
  intersection

# end of Set


#   that is either ordinary type variable or type variable standing for a constructor
#   with arbitrary type arguments
isNormalizedConstraint = (constraint) ->
  all (map isNormalizedConstraintArgument, constraint.types.types)

isNormalizedConstraintArgument = (type) ->
  if type instanceof TypeVariable
    yes
  else if type instanceof TypeConstr
    no
  else if type instanceof TypeApp
    isNormalizedConstraintArgument type.op.type


typeEq = (a, b) ->
  if a instanceof TypeVariable and b instanceof TypeVariable or
