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

型クラスを使って、「関数型の引数の型を取得する」関数を作る例

Open
#1,832 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

型クラスというのはこういう使い方もできる。

class FunArgs (α : Type) where
  args : Type

instance (priority := low) {α β : Type} : FunArgs (α → β) where
  args := α

instance {α β : Type} [FunArgs β] : FunArgs (α → β) where
  args := α × FunArgs.args β

example : FunArgs.args (Nat → Bool → Unit → Int) = (Nat × Bool × Unit) := rfl

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

The issue names no file or test; start with the supplied FunArgs Lean example and inspect the repository's existing example structure. Add an explanation and placement for retrieving function argument types, then verify that the displayed code and its rfl result are correct.

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.