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

derive Generic for phantom types #1380

Closed
zudov opened this issue Aug 13, 2015 · 4 comments
Closed

derive Generic for phantom types #1380

zudov opened this issue Aug 13, 2015 · 4 comments

Comments

@zudov
Copy link
Contributor

zudov commented Aug 13, 2015

Compiling the following code

data Void
derive instance genericVoid :: GenericVoid

Throws

psc: Prelude.head: empty list

The derived instance should probably look like

toSignature _ = SigProd []
fromSpine _ = Nothing
toSpine = absurd
@paf31 paf31 added this to the 0.8.0 milestone Aug 13, 2015
@zudov
Copy link
Contributor Author

zudov commented Aug 13, 2015

Defining Void as

newtype Void = Void Void

doesn't cause that problem (obviously because the constructor list isn't empty anymore :) )

@zudov zudov changed the title derive Generic for Void derive Generic for phantom types Aug 13, 2015
@paf31
Copy link
Contributor

paf31 commented Aug 14, 2015

@nicodelpiano Would you mind looking into this? I think it's in the exhaustivity checker.

@paf31
Copy link
Contributor

paf31 commented Aug 14, 2015

You can get the length of the list of arguments from the Case statement and pass it as a function argument.

@nicodelpiano
Copy link
Contributor

@paf31 Sure! I'm working on this.

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

No branches or pull requests

3 participants