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

Wingman: FIx evidence when using GADT constructors #1889

Merged
merged 8 commits into from Jun 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 16 additions & 1 deletion plugins/hls-tactics-plugin/src/Wingman/CodeGen.hs
Expand Up @@ -253,7 +253,22 @@ buildDataCon
-> [Type] -- ^ Type arguments for the data con
-> RuleM (Synthesized (LHsExpr GhcPs))
buildDataCon should_blacklist jdg dc tyapps = do
let args = conLikeInstOrigArgTys' dc tyapps
args <- case dc of
RealDataCon dc' -> do
let (skolems', theta, args) = dataConInstSig dc' tyapps
modify $ \ts ->
evidenceToSubst (foldMap mkEvidence theta) ts
& #ts_skolems <>~ S.fromList skolems'
pure args
_ ->
-- If we have a 'PatSyn', we can't continue, since there is no
-- 'dataConInstSig' equivalent for 'PatSyn's. I don't think this is
-- a fundamental problem, but I don't know enough about the GHC internals
-- to implement it myself.
--
-- Fortunately, this isn't an issue in practice, since 'PatSyn's are
-- never in the hypothesis.
throwError $ TacticPanic "Can't build Pattern constructors yet"
ext
<- fmap unzipTrace
$ traverse ( \(arg, n) ->
Expand Down
2 changes: 2 additions & 0 deletions plugins/hls-tactics-plugin/test/CodeAction/AutoSpec.hs
Expand Up @@ -66,6 +66,7 @@ spec = do
autoTest 6 10 "AutoThetaRefl"
autoTest 6 8 "AutoThetaReflDestruct"
autoTest 19 30 "AutoThetaMultipleUnification"
autoTest 16 9 "AutoThetaSplitUnification"

describe "known" $ do
autoTest 25 13 "GoldenArbitrary"
Expand All @@ -83,4 +84,5 @@ spec = do

describe "messages" $ do
mkShowMessageTest allFeatures Auto "" 2 8 "MessageForallA" TacticErrors
mkShowMessageTest allFeatures Auto "" 7 8 "MessageCantUnify" TacticErrors

@@ -0,0 +1,17 @@
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE TypeOperators #-}

data A = A
data B = B
data X = X
data Y = Y


data Pairrow ax by where
Pairrow :: (a -> b) -> (x -> y) -> Pairrow '(a, x) '(b, y)

test2 :: (A -> B) -> (X -> Y) -> Pairrow '(A, X) '(B, Y)
test2 = Pairrow

@@ -0,0 +1,17 @@
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE TypeOperators #-}

data A = A
data B = B
data X = X
data Y = Y


data Pairrow ax by where
Pairrow :: (a -> b) -> (x -> y) -> Pairrow '(a, x) '(b, y)

test2 :: (A -> B) -> (X -> Y) -> Pairrow '(A, X) '(B, Y)
test2 = _

8 changes: 8 additions & 0 deletions plugins/hls-tactics-plugin/test/golden/MessageCantUnify.hs
@@ -0,0 +1,8 @@
{-# LANGUAGE DataKinds, GADTs #-}

data Z ab where
Z :: (a -> b) -> Z '(a, b)

test :: Z ab
test = _