google-research / dex-lang

Research language for array processing in the Haskell/ML family
BSD 3-Clause "New" or "Revised" License
1.56k stars 106 forks source link

Cache type and effect parameters to HOFs. #1303

Closed dougalm closed 1 year ago

dougalm commented 1 year ago

To figure out the relevant types for HOFs like For and RunState we used to query the binders on their lambda parameters. That sometimes involved some awkward partiality due to assumed-successful hoisting. But more importantly it will become harder to do once we have type blocks. Querying the type of a lambda binder will give us some decls that we have to emit or go under. And hoisting a type that we expect to not dependent on a binder might fail because of spurious decls rather than true dependence. With this change, the HOFs just take extra type parameters for their relevant types, just as they would if they were regular library-level Dex functions, and there's never a need to query the lambda binders.