-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Don't defunctionalize helpers for class defaults or instance methods
`singletons-th` generates "helper" type families that contain the definitions of class method defaults or instance methods. For example, this: ```hs class C a where m :: a -> b -> a m x _ = x ``` Will be promoted to this: ```hs class PC a where type M (x :: a) (y :: b) :: a type M x y = MHelperSym0 `Apply` x `Apply` y type MHelper :: a -> b -> a type family MHelper x y where MHelper x _ = x type MHelperSym0 :: a ~> b ~> a type MHelperSym1 :: a -> b ~> a ... ``` Generating defunctionalization symbols for `MHelper` is wasteful, however, as we never really _need_ to partially apply `MHelper`. Instead, we can just generate this code: ```hs class PC a where type M (x :: a) (y :: b) :: a type M x y = MHelper x y ``` This takes advantage of the fact that when we apply `MHelper`, we always fully apply it to all of its arguments. This means that we can avoid generating defunctionalization symbols for helper type families altogether, which is a nice optimization. This patch implements that idea, fixing #608 in the process.
- Loading branch information
1 parent
f44bf07
commit 553e250
Showing
37 changed files
with
150 additions
and
2,485 deletions.
There are no files selected for viewing
162 changes: 6 additions & 156 deletions
162
singletons-base/tests/compile-and-dump/GradingClient/Database.golden
Large diffs are not rendered by default.
Oops, something went wrong.
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.