leanprover / leanprover/fp-lean

`deriving Repr` no longer required for structures?

Open
#180 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Lean
Stars
192
Forks
73
PR merge metrics
No merged PRs in 30d

Description

Please quote the text that is incorrect:

https://lean-lang.org/functional_programming_in_lean/getting-to-know/structures.html

If the deriving Repr line in Point's definition were omitted, then attempting #eval origin would yield an error similar to that which occurs when omitting a function's argument:

expression
origin
has type
Point
but instance
Lean.MetaEval Point
failed to be synthesized, this instance instructs Lean on how to display the resulting value, recall that any type implementing the Repr class also implements the Lean.MetaEval class

That message is saying that the evaluation machinery doesn't know how to communicate the result of evaluation back to the user.

In what way is this incorrect?

This appears to be outdated / no longer true for the current version of Lean - Even when the deriving Repr line is omitted, it's able to read and print the { ... } syntax without issues.

https://live.lean-lang.org/#codez=M4FwTgrgxiFgpgAgAoHsCWA7EiDuALeBAKEUQA9EAuRAMQBtUBDEUxAT2rsZeLYBN4AM0Sow6AOZYuaLDioBeRAG9yixAAYANB3UaAvmwDE8AG5N6o8VMxA

I suppose it's good practice to include the declaration anyway, but this had me confused me for a while, thinking I had misunderstood some part of the syntax.

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 with the quoted passage in the structures chapter at the linked Functional Programming in Lean page, then reproduce the example in the linked Lean playground with and without deriving Repr. Confirm the behavior for the current Lean version and update the explanation so it matches the result while preserving any guidance about when declaring Repr is useful.

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.