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
21 lines
533 B
Text
21 lines
533 B
Text
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
|