lean4-htt/tests/compiler/reduceArity_overapp.lean
Rob23oba eba5a5a6ef
fix: consider over-applications in reduceArity compiler pass (#11185)
This PR fixes the `reduceArity` compiler pass to consider
over-applications to functions that have their arity reduced.
Previously, this pass assumed that the amount of arguments to
applications was always the same as the number of parameters in the
signature. This is usually true, since the compiler eagerly introduces
parameters as long as the return type is a function type, resulting in a
function with a return type that isn't a function type. However, for
dependent types that sometimes are function types and sometimes not,
this assumption is broken, resulting in the additional parameters to be
dropped.

Closes #11131
2025-11-17 07:51:37 +00:00

21 lines
533 B
Text
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

def tuple (types : List Type) : Type :=
match types with
| [] => Unit
| [t] => t
| t :: types => t × tuple types
def uncurried ins out := tuple ins -> out
def curried (ins : List Type) out := match ins with
| [] => out
| (x :: xs) => x -> curried xs out
def curry (f : uncurried ins out) : curried ins out :=
match ins with
| [] => f ()
| [_] => f
| (_ :: _ :: _) => λx => curry (λxs => f (x, xs))
def main : IO Unit := do
let val : String := curry (ins := [Int, String]) Prod.snd 1 "a"
IO.println val