Skip to content
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

WIP: Add quantified constraint superclasses #21

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Ericson2314
Copy link
Contributor

@Ericson2314 Ericson2314 commented Jan 27, 2020

This will not work unless haskell/core-libraries-committee#10 is accepted.

Copy link
Collaborator

@phadej phadej left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i won't accept PRs making API conditional to GHC version.

I'm also don't feel bumping GHC support to GHC-8.6 just yet.

I also don't understand the motivation. I'd recommend to not use this class for anything else other than an auxiliary class for Show (Some f) instance.

#if __GLASGOW_HASKELL__ >= 806
, forall x. Show (a x)
, forall x. Show (b x)
#endif
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i don't understand this. shouldn't GShow a imply forall x. Show (a x), because it's class forall x. Show (t x)) => GShow t. Why GHC doesn't accept this?

@Ericson2314
Copy link
Contributor Author

Ericson2314 commented Apr 8, 2022

So since this PR was written, I made haskell/core-libraries-committee#10. That has has the superclass for the same reason.

Show1 f is slightly stronger than forall a. Show (f a). GShow f however is identical ind expressive power to forall a. Show (f a) and thus I am not whether it ought to existing if 8.6 ever become a lower bound.

@phadej
Copy link
Collaborator

phadej commented Apr 8, 2022

It's not identifical to Show1. GShow doesn't need Show a / a -> Int -> ShowS. GShow is unrestricted.

@phadej
Copy link
Collaborator

phadej commented Apr 8, 2022

Yes. Let's reconsider this when i bump the lower bound to GHC-8.6. i don't see a need to do that.

(if that going to happen I'd probably just remove the class all-together).

@Ericson2314
Copy link
Contributor Author

Ericson2314 commented Apr 8, 2022

I'll just turn this to a 8.6+ PR that does quantified constraints for all the classes. And mark it draft.

@Ericson2314 Ericson2314 changed the title WIP: Add forall a. Show (t a) superclass to GShow -- contains #20 FlexibleInstances Apr 8, 2022
@Ericson2314 Ericson2314 marked this pull request as draft April 8, 2022 16:24
@Ericson2314 Ericson2314 changed the title FlexibleInstances WIP: Add quantified constraint superclasses Apr 8, 2022
@@ -108,6 +81,9 @@ type GRead :: (k -> Type) -> Constraint
class GRead t where
greadsPrec :: Int -> GReadS t

-- (forall a. Read (t a)) =>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really should be

Suggested change
-- (forall a. Read (t a)) =>
-- (exists a. Read (t a)) =>

GRead ((:~:) a) only reads a :~: a, we're not going to create non-trivial :~: out of nothing. Likewise, in #45 we have

instance forall k1 k2 (a :: k1). k1 ~ k2 => GRead ((:~~:) a :: k2 -> Type)

which is more clearly written (at the cost of less back compat) as

instance forall k1 k2 (a :: k1). k1 ~ k2 => GRead ((:~~:) @k1 @k2 a)

We can only attempt to read when the kinds are the same and there isn't, in fact, any heterogeneity.

@Ericson2314
Copy link
Contributor Author

Once GHC 9.6 comes out we can give this another look.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants