Skip to content

Commit 82886f8

Browse files
Less aggressive refine tactic (#1475)
* Use try' everywhere * Make refine much less aggressive Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
1 parent 3095662 commit 82886f8

File tree

4 files changed

+21
-12
lines changed

4 files changed

+21
-12
lines changed

plugins/hls-tactics-plugin/src/Ide/Plugin/Tactic/KnownStrategies.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ module Ide.Plugin.Tactic.KnownStrategies where
55
import Control.Monad.Error.Class
66
import Ide.Plugin.Tactic.Context (getCurrentDefinitions)
77
import Ide.Plugin.Tactic.KnownStrategies.QuickCheck (deriveArbitrary)
8-
import Ide.Plugin.Tactic.Machinery (tracing)
8+
import Ide.Plugin.Tactic.Machinery (tracing, try')
99
import Ide.Plugin.Tactic.Tactics
1010
import Ide.Plugin.Tactic.Types
1111
import OccName (mkVarOcc)
@@ -29,7 +29,7 @@ known name t = do
2929

3030
deriveFmap :: TacticsM ()
3131
deriveFmap = do
32-
try intros
32+
try' intros
3333
overAlgebraicTerms homo
3434
choice
3535
[ overFunctions apply >> auto' 2

plugins/hls-tactics-plugin/src/Ide/Plugin/Tactic/Machinery.hs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,3 +272,16 @@ requireConcreteHole m = do
272272
0 -> m
273273
_ -> throwError TooPolymorphic
274274

275+
276+
------------------------------------------------------------------------------
277+
-- | The 'try' that comes in refinery 0.3 causes unnecessary backtracking and
278+
-- balloons the search space. This thing just tries it, but doesn't backtrack
279+
-- if it fails.
280+
--
281+
-- TODO(sandy): Remove this when we upgrade to 0.4
282+
try'
283+
:: Functor m
284+
=> TacticT jdg ext err s m ()
285+
-> TacticT jdg ext err s m ()
286+
try' t = commit t $ pure ()
287+

plugins/hls-tactics-plugin/src/Ide/Plugin/Tactic/Tactics.hs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -309,21 +309,17 @@ localTactic t f = do
309309

310310

311311
refine :: TacticsM ()
312-
refine = go 3
313-
where
314-
go 0 = pure ()
315-
go n = do
316-
let try_that_doesnt_suck t = commit t $ pure ()
317-
try_that_doesnt_suck intros
318-
try_that_doesnt_suck splitSingle
319-
go $ n - 1
312+
refine = do
313+
try' intros
314+
try' splitSingle
315+
try' intros
320316

321317

322318
auto' :: Int -> TacticsM ()
323319
auto' 0 = throwError NoProgress
324320
auto' n = do
325321
let loop = auto' (n - 1)
326-
try intros
322+
try' intros
327323
choice
328324
[ overFunctions $ \fname -> do
329325
apply fname
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
test :: ((), (b, c), d)
2-
test = ((), (_, _), _)
2+
test = (_, _, _)
33

0 commit comments

Comments
 (0)