lean4-htt/tests/lean/interactive/complete_field.lean
Leonardo de Moura c52be7e8c5 feat(frontends/lean,shell): autocompletion for ^.
@kha, I added autocompletion for ^. I try to elaborate the expression
before ^. using the local context provided by the parser.

The autocompletion only works if the type for the expression before ^. can be
inferred. This is a big limitation because this information cannot be
obtained in many cases. Here are examples that do not work:

  meta def proof_for (e : expr) : smt_tactic expr :=
  do cc ← to_cc_state, cc^.proof_for e
                         --^ does not work here

If we annotate cc with its type, it works:

  meta def proof_for (e : expr) : smt_tactic expr :=
  do cc : cc_state ← to_cc_state, cc^.proof_for e
                                    --^ works

We don't have typing information on the equation lhs at
autocompletion time. So, the following will not work

   private meta def mk_smt_goals_for (cfg : smt_config)
        : list expr → list smt_goal → list expr → tactic (list smt_goal × list expr)
   | []        sr tr := return (sr^.reverse, tr^.reverse)
                                  --^ does not work since
   | (tg::tgs) sr tr := ...
2017-01-17 19:27:59 -08:00

17 lines
530 B
Text
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

variables (α : Type) (p q : α → Prop)
example (h : ∀ x : α, p x ∧ q x) : ∀ y : α, p y :=
λ y : α, (h y)^.l
--^ "command": "complete"
example (h : ∀ x : α, p x ∧ q x) : ∀ y : α, p y :=
λ y : α, (h y)^.le
--^ "command": "complete"
example (h : ∀ x : α, p x ∧ q x) : ∀ y : α, q y :=
λ y : α, (h y)^.r
--^ "command": "complete"
example (h : ∀ x : α, p x ∧ q x) : ∀ y : α, q y :=
λ y : α, (h y)^.
--^ "command": "complete"