Tactic plugin: Excludes Dictionary arguments in GADTs in Destruct Tactic#474
Merged
Conversation
Collaborator
Collaborator
Author
|
OMG it hangs with >= 8.8... |
…ls `dataConInstArgTys` and selecting only non-class types
Collaborator
Author
|
I introduced the variant of |
Member
|
Yeah |
Collaborator
Author
|
Ok, it seems all CI passed! |
Collaborator
|
Looks great! Thanks so much, @konn! |
isovector
approved these changes
Oct 7, 2020
jneira
approved these changes
Oct 7, 2020
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Consider the following:
{-# LANGUAGE GADTs #-} module GoldenGADTDestruct where data CtxGADT where MkCtxGADT :: (Show a, Eq a) => a -> CtxGADT ctxGADT :: CtxGADT -> String ctxGADT gadt = _deconsIf we select
case split on gadtat_decons, the Tactic Plugin in HEAD introduces instance dictionary in data constructor:{-# LANGUAGE GADTs #-} module T4 where data CtxGADT where MkCtxGADT :: (Show a, Eq a) => a -> CtxGADT ctxGADT :: CtxGADT -> Bool ctxGADT gadt = (case gadt of { (MkCtxGADT sa ea a) -> _ })As it stands, generated pattern includes dictionary argumetns, which must not (cannot) appear in the source language.
This behaviour is due to the call to the
dataConInstArgTys, which also includes dictionary argument.This pull-request changes to use
dataConInstOrigArgTys, which excludes dictionaries and adds a golden test for destructing GADTs, and the above case-splitting generates the expected result:One concern: I also change the use of
dataConInstArgTysinbuildDataContodataConInstOrigArgTys. This should also correct the expression constructed by Homo or Auto tactic, but the generated expressions don't take type-level constraints into account. Any thoughts?