           }
           fallthrough
       case let .apply(_, appliedFnReg, _, appliedArgs, appliedFnType):
-        guard case let .functionType(appliedArgTypes, resultType) = unwrapFunctionType(appliedFnType) else {
+        guard case let .functionType(appliedArgTypes, resultType) = simplifyType(appliedFnType) else {
           fatalError("Expected a function type in .apply, got: \(appliedFnType)")
         }
         guard let (name: name, args: bundleArgs, argTypes: bundleArgTypes) = resolveFunction(appliedFnReg) else {

  let freshName = count(from: 0)

  func freshVar(_ type: Type) -> AbstractValue? {
    switch removeOwnership(type) {
    case .namedType("Int"): return .int(.var(IntVar(freshName())))
    case .namedType("Bool"): return .bool(.var(freshBoolVar()))
    case .namedType("TensorShape"): return freshShapeValue()

        updates = [.function(name)]

      case let .partialApply(_, _, fn, _, args, fnType):
        guard case let .functionType(allArgTypes, _) = simplifyType(fnType) else {
          fatalError("Expected a function type in .partialApply, got: \(fnType)")
        }
        assert(allArgTypes.count >= args.count)
