================================================================================
lambdas/typedLambdas
================================================================================

import "pkl:test"

res1 = ((x: Int) -> x + 1).apply(42)
res2 = test.catch(() -> ((x: Int) -> x + 1).apply("wrong type"))

res3 = ((x: Int(isPositive)) -> x + 1).apply(42)
res4 = test.catch(() -> ((x: Int(isPositive)) -> x + 1).apply(-1))

foo {
  n = 3
  bar {
    res5 = ((str: String(length > n)) -> str).apply("abcde")
    res6 = test.catch(() -> ((str: String(length > n)) -> str).apply("abc"))
  }
}

foo2 = (foo) {
  n = 4
}

hidden isNotEmpty = (coll: Collection) -> !coll.isEmpty

res7 = ((x: List<String>(isNotEmpty), y: Set<String>(isNotEmpty)) -> x.toSet() == y).apply(List("a", "b"), Set("b", "a"))

--------------------------------------------------------------------------------

(module
  (importClause
    (stringConstant))
  (classProperty
    (identifier)
    (methodCallExpr
      (parenthesizedExpr
        (functionLiteral
          (parameterList
            (typedIdentifier
              (identifier)
              (typeAnnotation
                (type
                  (qualifiedIdentifier
                    (identifier))))))
          (binaryExpr
            (variableExpr
              (identifier))
            (intLiteral))))
      (identifier)
      (argumentList
        (intLiteral))))
  (classProperty
    (identifier)
    (methodCallExpr
      (variableExpr
        (identifier))
      (identifier)
      (argumentList
        (functionLiteral
          (parameterList)
          (methodCallExpr
            (parenthesizedExpr
              (functionLiteral
                (parameterList
                  (typedIdentifier
                    (identifier)
                    (typeAnnotation
                      (type
                        (qualifiedIdentifier
                          (identifier))))))
                (binaryExpr
                  (variableExpr
                    (identifier))
                  (intLiteral))))
            (identifier)
            (argumentList
              (slStringLiteral)))))))
  (classProperty
    (identifier)
    (methodCallExpr
      (parenthesizedExpr
        (functionLiteral
          (parameterList
            (typedIdentifier
              (identifier)
              (typeAnnotation
                (type
                  (type
                    (qualifiedIdentifier
                      (identifier)))
                  (variableExpr
                    (identifier))))))
          (binaryExpr
            (variableExpr
              (identifier))
            (intLiteral))))
      (identifier)
      (argumentList
        (intLiteral))))
  (classProperty
    (identifier)
    (methodCallExpr
      (variableExpr
        (identifier))
      (identifier)
      (argumentList
        (functionLiteral
          (parameterList)
          (methodCallExpr
            (parenthesizedExpr
              (functionLiteral
                (parameterList
                  (typedIdentifier
                    (identifier)
                    (typeAnnotation
                      (type
                        (type
                          (qualifiedIdentifier
                            (identifier)))
                        (variableExpr
                          (identifier))))))
                (binaryExpr
                  (variableExpr
                    (identifier))
                  (intLiteral))))
            (identifier)
            (argumentList
              (unaryExpr
                (intLiteral))))))))
  (classProperty
    (identifier)
    (objectBody
      (objectProperty
        (identifier)
        (intLiteral))
      (objectProperty
        (identifier)
        (objectBody
          (objectProperty
            (identifier)
            (methodCallExpr
              (parenthesizedExpr
                (functionLiteral
                  (parameterList
                    (typedIdentifier
                      (identifier)
                      (typeAnnotation
                        (type
                          (type
                            (qualifiedIdentifier
                              (identifier)))
                          (binaryExpr
                            (variableExpr
                              (identifier))
                            (variableExpr
                              (identifier)))))))
                  (variableExpr
                    (identifier))))
              (identifier)
              (argumentList
                (slStringLiteral))))
          (objectProperty
            (identifier)
            (methodCallExpr
              (variableExpr
                (identifier))
              (identifier)
              (argumentList
                (functionLiteral
                  (parameterList)
                  (methodCallExpr
                    (parenthesizedExpr
                      (functionLiteral
                        (parameterList
                          (typedIdentifier
                            (identifier)
                            (typeAnnotation
                              (type
                                (type
                                  (qualifiedIdentifier
                                    (identifier)))
                                (binaryExpr
                                  (variableExpr
                                    (identifier))
                                  (variableExpr
                                    (identifier)))))))
                        (variableExpr
                          (identifier))))
                    (identifier)
                    (argumentList
                      (slStringLiteral)))))))))))
  (classProperty
    (identifier)
    (objectLiteral
      (parenthesizedExpr
        (variableExpr
          (identifier)))
      (objectBody
        (objectProperty
          (identifier)
          (intLiteral)))))
  (classProperty
    (modifier)
    (identifier)
    (functionLiteral
      (parameterList
        (typedIdentifier
          (identifier)
          (typeAnnotation
            (type
              (qualifiedIdentifier
                (identifier))))))
      (propertyCallExpr
        (unaryExpr
          (variableExpr
            (identifier)))
        (identifier))))
  (classProperty
    (identifier)
    (methodCallExpr
      (parenthesizedExpr
        (functionLiteral
          (parameterList
            (typedIdentifier
              (identifier)
              (typeAnnotation
                (type
                  (type
                    (qualifiedIdentifier
                      (identifier))
                    (typeArgumentList
                      (type
                        (qualifiedIdentifier
                          (identifier)))))
                  (variableExpr
                    (identifier)))))
            (typedIdentifier
              (identifier)
              (typeAnnotation
                (type
                  (type
                    (qualifiedIdentifier
                      (identifier))
                    (typeArgumentList
                      (type
                        (qualifiedIdentifier
                          (identifier)))))
                  (variableExpr
                    (identifier))))))
          (binaryExpr
            (methodCallExpr
              (variableExpr
                (identifier))
              (identifier)
              (argumentList))
            (variableExpr
              (identifier)))))
      (identifier)
      (argumentList
        (methodCallExpr
          (identifier)
          (argumentList
            (slStringLiteral)
            (slStringLiteral)))
        (methodCallExpr
          (identifier)
          (argumentList
            (slStringLiteral)
            (slStringLiteral)))))))
