 constraintsFromInstance = (ctx, constraint) ->
   {className, type} = constraint
   for instance in (ctx.classNamed className).instances
+    freshed = freshInstance ctx, instance.type
     # log "trying to find the instance", (printType instance.type.type), (printType constraint)
-    substitution = toMatchTypes instance.type.type.types, constraint.types
+    substitution = toMatchTypes freshed.type.types, constraint.types
     if substitution
+      # log substitution
       ctx.extendSubstitution substitution
-      return map ((c) -> substitute substitution, c), instance.type.constraints
+      return map ((c) -> substitute substitution, c), freshed.constraints
   null
 
 _names = (list) ->

instanceDictFor = (ctx, constraint) ->
  for {name, type} in (ctx.classNamed constraint.className).instances
    # TODO: support lookup of composite types, by traversing left depth-first
    if toMatchTypes type.type.types, constraint.types
      return validIdentifier name
  throw new Error "no instance for #{safePrintType constraint}"


      jsNoop()
    else
      freshConstraints = freshInstanceType.constraints
      instance = quantifyAll (new Constrained freshConstraints,
        (new ClassConstraint instanceType.className, freshInstanceType.type))
      ## if overlaps ctx, instance
      ##   malformed 'instance overlaps with another', instance
