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

Dynamic を使用して動的型付け言語のようなことをやる例

Open
#786 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 >
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

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

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.