lean-ja / lean-ja/lean-by-example
構造体(structure)のフィールドを部分的に更新するdo構文を作る。macro_rules コマンド使用例
Open
Nobody has claimed this yet.
コード例
メタプログラミング
メモ
要調査
- Dominant language
- Lean
- Stars
- 188
- Forks
- 15
- Avg merge
- 9h 8m
- Merged PRs (30d)
- 6
Description
Zulip: notation for unpacking structures and field assignment
mkIdentFrom などの良い使用例になっている。本文で紹介するためには、私が実装の詳細をきちんと理解する必要がある。
import Lean
open Lean Parser
macro_rules
| `(doElem| $x:ident := $val) => do
let .str n f := x.getId | Macro.throwUnsupported
if n == .anonymous then Macro.throwUnsupported
let o := mkIdentFrom x n
let field := mkIdentFrom x (Name.mkSimple f)
`(doElem| $o:ident := {$o with $field:ident := $val})
#guard show Bool from Id.run do
let mut s := (1,2)
s.fst := 3
s == (3, 2)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked Zulip discussion and the shown macro_rules example, then inspect the uses of mkIdentFrom and the #guard example. Document this partial structure-field update do syntax in the relevant book section, including the macro_rules usage. Done when the implementation details and runnable example are clearly explained.
Written by the indexing model from the issue text.
Assessment
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100