-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use TypeAbstractions
in singled data type definitions
#565
Comments
Looking at this a bit more, I think that we would first need to resolve goldfirere/th-desugar#199 before we could address this issue. This sounds doable, but I think it would take some time to get right. Moreover, I'd like to release a new version of |
See also #583. |
TypeAbstractions
in singletons-th
–generated codeTypeAbstractions
in singled data type definitions
goldfirere/th-desugar#199 has been fixed, which means that we can revisit this. At minimum, wrinkle 2 in SC :: forall a. SD (C :: D a) We could instead single it to this: SC :: forall a. SD (C @a) But what if the user had written One might wonder if there are any situations where visible kind applications would be necessary in situations where explicit return kinds don't suffice. For example, what if the user had declared this data type? data D where
C :: forall a. D Then it wouldn't suffice to write type CSym0 :: forall a. D
type family CSym0 @a :: D where
CSym0 = C But GHC will reject this:
I imagine that there would be various other issues of this sort in the code that As such, I'm inclined to leave wrinkle 3 of the Note in place, but with some expanded commentary on why we use explicit return kinds instead of visible kind applications. |
…f type variables during singling] Now that goldfirere/th-desugar#199 has been fixed, `singletons-th` can always guarantee that the type variable specificities that it reifies will be accurate. As such, all of wrinkle 2 in `Note [Preserve the order of type variables during singling]` is moot, so this PR deletes this wrinkle entirely. Wrinkle 3 has now been renamed to wrinkle 2. What was formerly known as wrinkle 3 is mostly kept the same, although I have expanded upon it a little to clarify what we single data constructors such as `Nothing :: forall a. Maybe a` to `SNothing :: forall a. SMaybe (Nothing :: Maybe a)` rather than, say, `SNothing :: forall a. SMaybe (Nothing @A)`. For instance, imagine if `a` was inferred rather than specified! I have added a `T565` test case which ensures that `singletons-th` generates valid code for the case when a data constructor uses an inferred type variable binder. I have also added an addendum to the `README` noting that `singletons-th` does not currently support `AllowAmbiguousTypes` at all, which would be perhaps the one convincing argument in favor of using explicit kind applications when singling return types (rather than explicit return kinds). Fixes #565.
GHC recently landed !9480, an implementation of GHC proposal #425. This introduces invisible
@k
-binders for type-level declarations, guarded behind theTypeAbstractions
extension. For example:With this, we can finally address
singletons-th
limitations that are described inNote [Preserve the order of type variables during singling]
:singletons/singletons-th/src/Data/Singletons/TH/Single/Type.hs
Lines 249 to 253 in 2c91ce4
singletons/singletons-th/src/Data/Singletons/TH/Single/Type.hs
Lines 320 to 328 in 2c91ce4
(Historical note: ghc-proposals/ghc-proposals#326 was an earlier iteration of what eventually became GHC proposal #425.)
It's possible that there are other use cases for
TypeAbstractions
withinsingletons
, but this is the one that first comes to mind.The text was updated successfully, but these errors were encountered: