     if expression.tea
       expression.tea = substitute ctx.substitution, expression.tea
     return
+  for scope in ctx.savedScopes when scope?
+    for name, def of values scope.definitions when def.type
+      def.type = substitute ctx.substitution, def.type
   return
 
 # end of API

filterSet =
filterMap = (fn, set) ->
  initialized = newMap()
  for key, val of set.values when fn key
    addToMap initialized, key, val
  initialized


    applyKindFn (applyKindFn fn, arg), args...

isConstructor = (type) ->
  type.TypeApp

kind = (type) ->
  if type.kind
    type.kind
  else if type.TypeApp
    (kind type.op).to
  else
    console.log "invalid", type
    throw new Error "Invalid type in kind"

kindsEq = (k1, k2) ->
