-
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.
promoteLetDecName: Fix visibility-related bug
Previously, `promoteLetDecName` would convert every `DTyVarBndrSpec` in an outermost `forall` to an invisible argument in a promoted type family equation. This is not quite right, however, as #585 reveals: we do not want to convert _inferred_ type variable binders to invisible arguments. To do this properly, we introduce a new `tvbSpecsToBndrVis` function, which converts a list of `DTyVarBndrSpec`s to a list of `DTyVarBndrVis`es, dropping any `DTyVarBndrSpec`s with an `InferredSpec` in the process. We then use `tvbSpecsToBndrVis` in `promoteLetDecName`, which neatly fixes #585.
- Loading branch information
1 parent
83705e7
commit f870b49
Showing
6 changed files
with
95 additions
and
3 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
40 changes: 40 additions & 0 deletions
40
singletons-base/tests/compile-and-dump/Singletons/T585.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,40 @@ | ||
Singletons/T585.hs:(0,0)-(0,0): Splicing declarations | ||
singletons | ||
[d| konst :: forall a {b}. a -> b -> a | ||
konst x _ = x |] | ||
======> | ||
konst :: forall a {b}. a -> b -> a | ||
konst x _ = x | ||
type KonstSym0 :: forall a {b}. (~>) a ((~>) b a) | ||
data KonstSym0 :: (~>) a ((~>) b a) | ||
where | ||
KonstSym0KindInference :: SameKind (Apply KonstSym0 arg) (KonstSym1 arg) => | ||
KonstSym0 a0123456789876543210 | ||
type instance Apply KonstSym0 a0123456789876543210 = KonstSym1 a0123456789876543210 | ||
instance SuppressUnusedWarnings KonstSym0 where | ||
suppressUnusedWarnings = snd ((,) KonstSym0KindInference ()) | ||
type KonstSym1 :: forall a {b}. a -> (~>) b a | ||
data KonstSym1 (a0123456789876543210 :: a) :: (~>) b a | ||
where | ||
KonstSym1KindInference :: SameKind (Apply (KonstSym1 a0123456789876543210) arg) (KonstSym2 a0123456789876543210 arg) => | ||
KonstSym1 a0123456789876543210 a0123456789876543210 | ||
type instance Apply (KonstSym1 a0123456789876543210) a0123456789876543210 = Konst a0123456789876543210 a0123456789876543210 | ||
instance SuppressUnusedWarnings (KonstSym1 a0123456789876543210) where | ||
suppressUnusedWarnings = snd ((,) KonstSym1KindInference ()) | ||
type KonstSym2 :: forall a {b}. a -> b -> a | ||
type family KonstSym2 (a0123456789876543210 :: a) (a0123456789876543210 :: b) :: a where | ||
KonstSym2 a0123456789876543210 a0123456789876543210 = Konst a0123456789876543210 a0123456789876543210 | ||
type Konst :: forall a {b}. a -> b -> a | ||
type family Konst (a :: a) (a :: b) :: a where | ||
Konst @a (x :: a) (_ :: b) = x | ||
sKonst :: | ||
forall a {b} (t :: a) (t :: b). Sing t | ||
-> Sing t -> Sing (Apply (Apply KonstSym0 t) t :: a) | ||
sKonst (sX :: Sing x) _ = sX | ||
instance SingI (KonstSym0 :: (~>) a ((~>) b a)) where | ||
sing = singFun2 @KonstSym0 sKonst | ||
instance SingI d => SingI (KonstSym1 (d :: a) :: (~>) b a) where | ||
sing = singFun1 @(KonstSym1 (d :: a)) (sKonst (sing @d)) | ||
instance SingI1 (KonstSym1 :: a -> (~>) b a) where | ||
liftSing (s :: Sing (d :: a)) | ||
= singFun1 @(KonstSym1 (d :: a)) (sKonst s) |
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,8 @@ | ||
module T585 where | ||
|
||
import Data.Singletons.TH | ||
|
||
$(singletons [d| | ||
konst :: forall a {b}. a -> b -> a | ||
konst x _ = x | ||
|]) |
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