Skip to content

Commit b586b85

Browse files
committed
Add application, add split, rename split to ctor
1 parent 3383f64 commit b586b85

File tree

3 files changed

+20
-5
lines changed

3 files changed

+20
-5
lines changed

plugins/hls-tactics-plugin/src/Wingman/Metaprogramming/Lexer.hs

+3
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ brackets = P.between (symbol "[") (symbol "]")
4545
braces :: Parser a -> Parser a
4646
braces = P.between (symbol "{") (symbol "}")
4747

48+
parens :: Parser a -> Parser a
49+
parens = P.between (symbol "(") (symbol ")")
50+
4851
identifier :: Text -> Parser ()
4952
identifier i = lexeme (P.string i *> P.notFollowedBy ichar)
5053

plugins/hls-tactics-plugin/src/Wingman/Metaprogramming/Parser.hs

+14-5
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,13 @@ unary_occ name tac = tac <$> (identifier name *> variable)
2929
variadic_occ :: T.Text -> ([OccName] -> TacticsM ()) -> Parser (TacticsM ())
3030
variadic_occ name tac = tac <$> (identifier name *> P.many variable)
3131

32-
33-
tactic :: Parser (TacticsM ())
34-
tactic = flip P.makeExprParser operators $ P.choice
32+
oneTactic :: Parser (TacticsM ())
33+
oneTactic =
34+
P.choice
3535
[ braces tactic
36+
-- TODO(sandy): lean uses braces for control flow, but i always forget
37+
-- and want to use parens. is there a semantic difference?
38+
, parens tactic
3639
, nullary "assumption" assumption
3740
, unary_occ "assume" assume
3841
, variadic_occ "intros" $ \case
@@ -42,19 +45,25 @@ tactic = flip P.makeExprParser operators $ P.choice
4245
, nullary "destruct_all" destructAll
4346
, unary_occ "destruct" $ useNameFromHypothesis destruct
4447
, unary_occ "homo" $ useNameFromHypothesis homo
48+
, nullary "application" application
4549
, unary_occ "apply" $ useNameFromHypothesis apply
46-
, unary_occ "split" userSplit
50+
, nullary "split" split
51+
, unary_occ "ctor" userSplit
4752
, nullary "obvious" obvious
4853
, nullary "auto" auto
49-
, R.try <$> (keyword "try" *> tactic)
5054
]
5155

56+
57+
tactic :: Parser (TacticsM ())
58+
tactic = flip P.makeExprParser operators oneTactic
59+
5260
bindOne :: TacticsM a -> TacticsM a -> TacticsM a
5361
bindOne t t1 = t R.<@> [t1]
5462

5563
operators :: [[P.Operator Parser (TacticsM ())]]
5664
operators =
5765
[ [ P.Prefix (symbol "*" $> R.many_) ]
66+
, [ P.Prefix (symbol "try" $> R.try) ]
5867
, [ P.InfixR (symbol "|" $> (R.<%>) )]
5968
, [ P.InfixL (symbol ";" $> (>>))
6069
, P.InfixL (symbol "," $> bindOne)

plugins/hls-tactics-plugin/src/Wingman/Tactics.hs

+3
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,9 @@ apply hi = requireConcreteHole $ tracing ("apply' " <> show (hi_name hi)) $ do
223223
& #syn_used_vals %~ S.insert func
224224
& #syn_val %~ mkApply func . fmap unLoc
225225

226+
application :: TacticsM ()
227+
application = overFunctions apply
228+
226229

227230
------------------------------------------------------------------------------
228231
-- | Choose between each of the goal's data constructors.

0 commit comments

Comments
 (0)