lean-ja / lean-ja/lean-by-example

DSL をエラボレータで評価する/ elab 使用例

Open
#1,450 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

コード例 メタプログラミング
Dominant language
Lean
Stars
188
Forks
15
Avg merge
9h 8m
Merged PRs (30d)
6

Description

Zulip: > How to evaluate a DSL using the elaborator?

open Lean hiding Expr
open Qq
elab "⟦" x:term "⟧" : term => do
  let e ← unsafe Elab.Term.evalTerm Expr q(Expr) x
  match eval_closed e with
  | .inr n => return q($n)
  | .inl x => throwError "{x} occurs"

open Expr
#check ⟦ plus (num 3) (num 5) ⟧ -- this is elaborated to 8
#check ⟦ plus (num 3) (var "x") ⟧ -- this reports an error: "x occurs"

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Begin with the linked Zulip discussion and the provided elaborator snippet. Find the repository location for comparable Lean-by-example entries and check how examples are organized and rendered. Done means the DSL evaluation example is added in the project’s established format and demonstrates both the successful evaluation and the variable error shown.

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
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.