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

Providing a GNFData instance for V1 #1

Closed
wants to merge 1 commit into from

Conversation

jkoppel
Copy link

@jkoppel jkoppel commented Sep 14, 2013

Although V1 is uninhabited, the lack of an instance for V1 prevents GHC from inferring an instance for types such as (U1 :+: V1), which very much is inhabited. I've encountered types like that when creating Generic instances for certain GADTs.

Although V1 is uninhabited, the lack of an instance for V1 prevents GHC from inferring an instance for types such as (U1 :+: V1), which very much is inhabited. I've encountered types like that when creating Generic instances for certain GADTs.
@ghost ghost assigned hvr Sep 14, 2013
@hvr
Copy link
Collaborator

hvr commented Sep 14, 2013

Can you provide a simple concrete example for when this applies?

@jkoppel
Copy link
Author

jkoppel commented Sep 14, 2013

Sure!

http://lpaste.net/92963

I've been working with GADTs similar to that example, but much larger, for the past 6 months. They're "multi-sorted compositional datatypes" (c.f.: the compdata package). I spent much of today figuring out how to write Generic instances for them before I generate them with TH -- took three or four tries, but my best answer uses V1.

hvr added a commit that referenced this pull request Sep 14, 2013
This addresses #1 by providing the new `genericRnfV1` function deferring
the otherwise resulting compile-time error to run-time, thereby allowing
for a conscious choice of whether deriving for `V1` types is acceptable.

This also bumps to version 0.1.1.0 and adds a Cabal 1.18 compatible
changelog.
@hvr
Copy link
Collaborator

hvr commented Sep 14, 2013

As I wanted to retain the ability to trigger compile-time errors, I've pursued a slightly different approach; If this works for you, I'd like to upload this to Hackage soon

@jkoppel
Copy link
Author

jkoppel commented Sep 14, 2013

There's a typo in the error message ("inhabited"->"uninhabited"), but that looks acceptable. Thanks!

@hvr
Copy link
Collaborator

hvr commented Sep 14, 2013

Thanks

I fixed the typo and released/uploaded deepseq-generics-0.1.1.0 to Hackage

@hvr hvr closed this Sep 14, 2013
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.

None yet

2 participants