lean4-htt/tests/lean/run/structure_default_value_issue.lean
Leonardo de Moura d775ee98b4 feat(frontends/lean): auto_param support at structure_instance, and better error messages
Summary:

- A field value was being elaborated more than once when there is
  another field whose default value depends on it.
  The new test `structure_default_value_issue.lean` exposes the problem.

- Better error message and localization at field type mismatches.
  When there is field type mismatch, the error message contains the
  field name, and the error is reported at the field position instead of
  `{`.

- We add support for auto_param at structure instances `{...}`
  See #1422
2017-03-08 18:04:36 -08:00

24 lines
690 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.

namespace test
universes u v w
structure lens (α : Type u) (β : Type v) :=
(get : α → β)
(modify : α → (β → β) → α)
(set : α → β → α := λ a b, modify a (λ _, b))
def lens.compose {α : Type u} {β : Type v} {σ : Type w} (t : lens β σ) (s : lens α β) : lens α σ :=
{ get := t^.get ∘ s^.get,
modify := λ a f, s^.modify a $ λ b, t^.modify b f,
set := λ a v, s^.modify a $ λ b, t^.set b v }
infix `∙`:1 := lens.compose
def fst {α β} : lens (α × β) α :=
{ get := prod.fst,
modify := λ ⟨a, b⟩ f, (f a, b) }
def snd {α β} : lens (α × β) β :=
{ get := prod.snd,
modify := λ ⟨a, b⟩ f, (a, f b) }
end test