 #       is not a function then it can't need type class dictionaries
 #       ^.___ not necessarily, we could have a tuple of functions or similar
 irDefinitionTranslate = (ctx, {type, expression, id}) ->
-  finalType = addConstraintsFrom ctx, {id, type}, substitute ctx.substitution, type
-  reducedConstraints = reduceConstraints ctx, finalType.constraints
+  finalType = substitute ctx.substitution, type
+  reducedConstraints = 
+    # if declaredType = ctx.typeForId id
+    #   constraintsFromCanonicalType ctx, declaredType, finalType
+    # else
+      reduceConstraints ctx, (addConstraintsFrom ctx, {id, type}, finalType).constraints
   ctx.updateClassParams()
   # TODO: what about the class dictionaries order?
   counter = {}

  else
    finalType = addConstraintsFrom ctx, {id, type}, substitute ctx.substitution, type
    classParams = dictsForConstraint ctx, finalType.constraints
    if classParams.length > 0
      (irFunctionTranslate ctx,
        params: arity
        body: [(jsReturn (jsCall (validIdentifier name), (join classParams, arity)))])
    else
      validIdentifier name


  [typed, notTyped] = partitionMap typesUnify, validDefinitions
  # allDefs = join (setToArray typed), (setToArray notTyped)
  allDefs = concatMaps typed, notTyped # TODO: don't use object key ordering for ordering
  values mapMap (__ plainPrettyPrint, _type), allDefs

# API

