leanprover / leanprover/lean4

RFC: introduce notations for `Duration` and `Timestamp` and remove dangerous `OfNat` instances

Open
#6,793 2 comments 5 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

P-medium RFC RFC accepted
Dominant language
Lean
Stars
9.2k
Forks
990
Avg merge
1d 17h
Merged PRs (30d)
175

Description

Proposal

We currently provide OfNat Duration and OfNat Timestamp instances which turn natural numbers into seconds and seconds since Unix epoch, respectively. Keeping with the design of "make incorrect conversions impossible and make dubious conversions explicit", we should change this as follows:

  • Introduce notation for Duration types (this was considered during initial implementation, but was postponed to reduce the size of the PR).
  • Add Timestamp.ofDurationSinceUnixEpoch (this is just the constructor).
  • Remove the OfNat Duration and OfNat Timestamp instances.
  • Possibly introduce notation for Timestamp that allows entering a timestamp with time zone in ISO format without having to go through ZonedDateTime.
Impact

Add 👍 to issues you consider important. If others benefit from the changes in this proposal being added, please ask them to add 👍 to it.

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 locating the Duration and Timestamp definitions and their current OfNat instances. Review how existing notation and ZonedDateTime APIs are implemented before assessing the proposed Duration notation and Timestamp.ofDurationSinceUnixEpoch constructor. Done would require an agreed design covering the notation, constructor, removal of both instances, and whether ISO timestamp notation is included.

Written by the indexing model from the issue text.

Assessment

Domain
compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.