Skip to content

Less aggressive refine tactic #1475

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

Merged
merged 4 commits into from
Mar 2, 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module Ide.Plugin.Tactic.KnownStrategies where
import Control.Monad.Error.Class
import Ide.Plugin.Tactic.Context (getCurrentDefinitions)
import Ide.Plugin.Tactic.KnownStrategies.QuickCheck (deriveArbitrary)
import Ide.Plugin.Tactic.Machinery (tracing)
import Ide.Plugin.Tactic.Machinery (tracing, try')
import Ide.Plugin.Tactic.Tactics
import Ide.Plugin.Tactic.Types
import OccName (mkVarOcc)
Expand All @@ -29,7 +29,7 @@ known name t = do

deriveFmap :: TacticsM ()
deriveFmap = do
try intros
try' intros
overAlgebraicTerms homo
choice
[ overFunctions apply >> auto' 2
Expand Down
13 changes: 13 additions & 0 deletions plugins/hls-tactics-plugin/src/Ide/Plugin/Tactic/Machinery.hs
Original file line number Diff line number Diff line change
Expand Up @@ -272,3 +272,16 @@ requireConcreteHole m = do
0 -> m
_ -> throwError TooPolymorphic


------------------------------------------------------------------------------
-- | The 'try' that comes in refinery 0.3 causes unnecessary backtracking and
-- balloons the search space. This thing just tries it, but doesn't backtrack
-- if it fails.
--
-- TODO(sandy): Remove this when we upgrade to 0.4
try'
:: Functor m
=> TacticT jdg ext err s m ()
-> TacticT jdg ext err s m ()
try' t = commit t $ pure ()

14 changes: 5 additions & 9 deletions plugins/hls-tactics-plugin/src/Ide/Plugin/Tactic/Tactics.hs
Original file line number Diff line number Diff line change
Expand Up @@ -309,21 +309,17 @@ localTactic t f = do


refine :: TacticsM ()
refine = go 3
where
go 0 = pure ()
go n = do
let try_that_doesnt_suck t = commit t $ pure ()
try_that_doesnt_suck intros
try_that_doesnt_suck splitSingle
go $ n - 1
refine = do
try' intros
try' splitSingle
try' intros


auto' :: Int -> TacticsM ()
auto' 0 = throwError NoProgress
auto' n = do
let loop = auto' (n - 1)
try intros
try' intros
choice
[ overFunctions $ \fname -> do
apply fname
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
test :: ((), (b, c), d)
test = ((), (_, _), _)
test = (_, _, _)