lean-ja / lean-ja/lean-by-example
Dynamic を使用して動的型付け言語のようなことをやる例
Open
Nobody has claimed this yet.
コード例
メモ
- Dominant language
- Lean
- Stars
- 188
- Forks
- 15
- Avg merge
- 9h 8m
- Merged PRs (30d)
- 6
Description
Zulip >
Using lean as a general language
def Item := Dynamic
def getValue (α : Type) [TypeName α] (values: List Item): List α :=
values.filterMap (·.get? α)
deriving instance TypeName for String
deriving instance TypeName for Nat
deriving instance TypeName for Float
#eval getValue String [.mk "hi", .mk "there", .mk 2, .mk 4.5] -- ["hi", "there"]
#eval getValue Nat [.mk "hi", .mk "there", .mk 2, .mk 4.5] -- [2]
#eval getValue Float [.mk "hi", .mk "there", .mk 2, .mk 4.5] -- [4.500000]
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 by reviewing the linked Zulip discussion and the supplied Lean Dynamic example. Locate the appropriate place in the Lean-by-example content for an example of dynamic-style type handling. Done means the example is added with its demonstrated String, Nat, and Float results and is consistent with the surrounding material.
Written by the indexing model from the issue text.
Assessment
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100