File tree 2 files changed +17
-8
lines changed
plugins/hls-tactics-plugin/src/Wingman
2 files changed +17
-8
lines changed Original file line number Diff line number Diff line change @@ -223,6 +223,16 @@ unify goal inst = do
223
223
Nothing -> throwError (UnificationError inst goal)
224
224
225
225
226
+ ------------------------------------------------------------------------------
227
+ -- | Prefer the first tactic to the second, if the bool is true. Otherwise, just run the second tactic.
228
+ --
229
+ -- This is useful when you have a clever pruning solution that isn't always
230
+ -- applicable.
231
+ attemptWhen :: TacticsM a -> TacticsM a -> Bool -> TacticsM a
232
+ attemptWhen _ t2 False = t2
233
+ attemptWhen t1 t2 True = commit t1 t2
234
+
235
+
226
236
------------------------------------------------------------------------------
227
237
-- | Get the class methods of a 'PredType', correctly dealing with
228
238
-- instantiation of quantified class types.
Original file line number Diff line number Diff line change @@ -131,14 +131,13 @@ destructOrHomoAuto hi = tracing "destructOrHomoAuto" $ do
131
131
let g = unCType $ jGoal jdg
132
132
ty = unCType $ hi_type hi
133
133
134
- let do_destruct = rule $ destruct' (const subgoal) hi
135
-
136
- case (splitTyConApp_maybe g, splitTyConApp_maybe ty) of
137
- (Just (gtc, apps), Just (tytc, _)) | gtc == tytc ->
138
- commit
139
- (rule $ destruct' (\ dc jdg -> buildDataCon False jdg dc apps) hi)
140
- do_destruct
141
- _ -> do_destruct
134
+ attemptWhen
135
+ (rule $ destruct' (\ dc jdg ->
136
+ buildDataCon False jdg dc $ snd $ splitAppTys g) hi)
137
+ (rule $ destruct' (const subgoal) hi)
138
+ $ case (splitTyConApp_maybe g, splitTyConApp_maybe ty) of
139
+ (Just (gtc, _), Just (tytc, _)) -> gtc == tytc
140
+ _ -> False
142
141
143
142
144
143
------------------------------------------------------------------------------
You can’t perform that action at this time.
0 commit comments