-
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.
Partially revert TypeAbstractions-related changes in #596
The changes in #596 cause `singletons-th` to use `TypeAbstractions` to explicitly quantify the kind variables of promoted class methods whenever the parent class has a standalone kind signature, thereby ensuring that the order of kind variables matches the order in which the user wrote them. At least, that was the intention. Unfortunately, as #605 reveals, this approach sometimes causes `singletons-th` to generate ill-kinded code for promoted class methods, and there isn't an obvious way to work around this limitation. As such, this patch reverts the `TypeAbstractions`-related changes from #596. Once again, `singletons-th` now does not make any guarantees about the order of kind variables for promoted class methods or their defunctionalization symbols. On the other hand, this patch _does_ keep the changes from #596 that cause `singletons-th` to propagate kind information from the parent class's standalone kind signature through to the promoted class methods' defunctionalization symbols, as this feature is useful independent of the `TypeAbstractions`-related changes. I have taken the opportunity to document why we do this in the new `Note [Propagating kind information from class standalone kind signatures]` in `D.S.TH.Promote`. I've removed the `T589` test case, as the functionality it was testing no longer exists after reverting the `TypeAbstractions`-related changes. I have also added a new `T605` test case that ensures that the regression from #605 stays fixed. In a subsequent commit, I will add another test case that demonstrates that the kind propagation works as intended. Fixes #605.
- Loading branch information
1 parent
2b4f955
commit 6c3c74f
Showing
15 changed files
with
262 additions
and
541 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
39 changes: 39 additions & 0 deletions
39
singletons-base/tests/compile-and-dump/Promote/T605.golden
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
Promote/T605.hs:(0,0)-(0,0): Splicing declarations | ||
promoteOnly | ||
[d| type Traversable' :: (Type -> Type) -> Constraint | ||
|
||
class (Functor t, Foldable t) => Traversable' t where | ||
traverse' :: Applicative f => (a -> f b) -> t a -> t (f b) |] | ||
======> | ||
type Traverse'Sym0 :: forall (t :: Type -> Type) | ||
a | ||
f | ||
b. (~>) ((~>) a (f b)) ((~>) (t a) (t (f b))) | ||
data Traverse'Sym0 :: (~>) ((~>) a (f b)) ((~>) (t a) (t (f b))) | ||
where | ||
Traverse'Sym0KindInference :: SameKind (Apply Traverse'Sym0 arg) (Traverse'Sym1 arg) => | ||
Traverse'Sym0 a0123456789876543210 | ||
type instance Apply Traverse'Sym0 a0123456789876543210 = Traverse'Sym1 a0123456789876543210 | ||
instance SuppressUnusedWarnings Traverse'Sym0 where | ||
suppressUnusedWarnings = snd ((,) Traverse'Sym0KindInference ()) | ||
type Traverse'Sym1 :: forall (t :: Type -> Type) | ||
a | ||
f | ||
b. (~>) a (f b) -> (~>) (t a) (t (f b)) | ||
data Traverse'Sym1 (a0123456789876543210 :: (~>) a (f b)) :: (~>) (t a) (t (f b)) | ||
where | ||
Traverse'Sym1KindInference :: SameKind (Apply (Traverse'Sym1 a0123456789876543210) arg) (Traverse'Sym2 a0123456789876543210 arg) => | ||
Traverse'Sym1 a0123456789876543210 a0123456789876543210 | ||
type instance Apply (Traverse'Sym1 a0123456789876543210) a0123456789876543210 = Traverse' a0123456789876543210 a0123456789876543210 | ||
instance SuppressUnusedWarnings (Traverse'Sym1 a0123456789876543210) where | ||
suppressUnusedWarnings = snd ((,) Traverse'Sym1KindInference ()) | ||
type Traverse'Sym2 :: forall (t :: Type -> Type) | ||
a | ||
f | ||
b. (~>) a (f b) -> t a -> t (f b) | ||
type family Traverse'Sym2 @(t :: Type | ||
-> Type) @a @f @b (a0123456789876543210 :: (~>) a (f b)) (a0123456789876543210 :: t a) :: t (f b) where | ||
Traverse'Sym2 a0123456789876543210 a0123456789876543210 = Traverse' a0123456789876543210 a0123456789876543210 | ||
type PTraversable' :: (Type -> Type) -> Constraint | ||
class PTraversable' t where | ||
type family Traverse' (arg :: (~>) a (f b)) (arg :: t a) :: t (f b) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
module T605 where | ||
|
||
import Data.Kind | ||
import Data.Singletons.Base.TH | ||
import Prelude.Singletons | ||
|
||
$(promoteOnly [d| | ||
type Traversable' :: (Type -> Type) -> Constraint | ||
class (Functor t, Foldable t) => Traversable' t where | ||
traverse' :: Applicative f => (a -> f b) -> t a -> t (f b) | ||
|]) |
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
127 changes: 0 additions & 127 deletions
127
singletons-base/tests/compile-and-dump/Singletons/T589.golden
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.