-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Don't use defunctionalization when singling return types of type sign…
…atures As noted in #608, you don't need to involve defunctionalization when promoting class method defaults, as we always know that the promoted versions of the defaults will be fully applied to all their arguments. In fact, there is another situation in which we always know that a promoted type family will be fully applied: the return type of a singled type signature. That it, if you single this definition: ```hs f :: a -> b -> a ``` You currently get this: ```hs sF :: forall a b (x :: a) (y :: b). Sing x -> Sing y -> Sing (FSym0 `Apply` x `Apply` y) ``` But using `FSym0` in the return type of `sF` is silly, however, as we always know that it will be fully applied to its arguments (`x` and `y`). As such, it would be far more direct to instead generate the following: ```hs sF :: forall a b (x :: a) (y :: b). Sing x -> Sing y -> Sing (F x y) ``` No defunctionalization required at all. This doesn't change the behavior of the singled code at all, but it is more direct and will likely require less time to typecheck due to fewer type family indirections being involved. To accomplish this, the `lde_proms` field now maps term-level names to `LetDecProm`s, where a `LetDecProm` consists of the promoted version of the name and the local variables that it closes over. In this context, "promoted version" means `F`, _not_ `FSym0`. Storing the non-defunctionalized name allows us to fully apply `F` whenever it is convenient to do so, and in situations where partial application may be required, we can always convert `F` to `FSym0` before generating the partial application.
- Loading branch information
1 parent
875a004
commit a351105
Showing
81 changed files
with
357 additions
and
507 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.