diff --git a/plugins/hls-tactics-plugin/src/Ide/Plugin/Tactic/Tactics.hs b/plugins/hls-tactics-plugin/src/Ide/Plugin/Tactic/Tactics.hs index 3df6f235bf..ab1932036a 100644 --- a/plugins/hls-tactics-plugin/src/Ide/Plugin/Tactic/Tactics.hs +++ b/plugins/hls-tactics-plugin/src/Ide/Plugin/Tactic/Tactics.hs @@ -191,11 +191,9 @@ split :: TacticsM () split = tracing "split(user)" $ do jdg <- goal let g = jGoal jdg - case splitTyConApp_maybe $ unCType g of + case tacticsGetDataCons $ unCType g of Nothing -> throwError $ GoalMismatch "split" g - Just (tc, _) -> do - let dcs = tyConDataCons tc - choice $ fmap splitDataCon dcs + Just (dcs, _) -> choice $ fmap splitDataCon dcs ------------------------------------------------------------------------------ diff --git a/plugins/hls-tactics-plugin/test/GoldenSpec.hs b/plugins/hls-tactics-plugin/test/GoldenSpec.hs index add283d012..bc60cac658 100644 --- a/plugins/hls-tactics-plugin/test/GoldenSpec.hs +++ b/plugins/hls-tactics-plugin/test/GoldenSpec.hs @@ -143,9 +143,12 @@ spec = do refineTest "RefineReader.hs" 4 8 refineTest "RefineGADT.hs" 8 8 + -- test via: + -- stack test hls-tactics-plugin --test-arguments '--match "Golden/golden tests/"' describe "golden tests" $ do let autoTest = mkGoldenTest allFeatures Auto "" + autoTest "AutoSplitGADT.hs" 11 8 goldenTest Intros "" "GoldenIntros.hs" 2 8 autoTest "GoldenEitherAuto.hs" 2 11 autoTest "GoldenJoinCont.hs" 4 12 diff --git a/plugins/hls-tactics-plugin/test/golden/AutoSplitGADT.hs b/plugins/hls-tactics-plugin/test/golden/AutoSplitGADT.hs new file mode 100644 index 0000000000..b15621e091 --- /dev/null +++ b/plugins/hls-tactics-plugin/test/golden/AutoSplitGADT.hs @@ -0,0 +1,12 @@ +{-# LANGUAGE GADTs #-} + +data GADT b a where + GBool :: b -> GADT b Bool + GInt :: GADT b Int + +-- wingman would prefer to use GBool since then it can use its argument. But +-- that won't unify with GADT Int, so it is forced to pick GInt and ignore the +-- argument. +test :: b -> GADT b Int +test = _ + diff --git a/plugins/hls-tactics-plugin/test/golden/AutoSplitGADT.hs.expected b/plugins/hls-tactics-plugin/test/golden/AutoSplitGADT.hs.expected new file mode 100644 index 0000000000..2521b651eb --- /dev/null +++ b/plugins/hls-tactics-plugin/test/golden/AutoSplitGADT.hs.expected @@ -0,0 +1,12 @@ +{-# LANGUAGE GADTs #-} + +data GADT b a where + GBool :: b -> GADT b Bool + GInt :: GADT b Int + +-- wingman would prefer to use GBool since then it can use its argument. But +-- that won't unify with GADT Int, so it is forced to pick GInt and ignore the +-- argument. +test :: b -> GADT b Int +test _ = GInt +