lean4-htt/tests/lean/run/ofNat_class.lean
David Thrane Christiansen 966fa800f8
chore: remove the coercion from String to Name (#3589)
This coercion caused difficult-to-diagnose bugs sometimes. Because there
are some situations where converting a string to a name should be done
by parsing the string, and others where it should not, an explicit
choice seems better here.

---------

Co-authored-by: Mac Malone <tydeu@hatpress.net>
2024-03-21 23:46:03 +00:00

15 lines
431 B
Text
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import Lean
open Lean
local macro "ofNat_class" Class:ident n:num : command =>
let field := Lean.mkIdent <| .mkSimple Class.getId.eraseMacroScopes.getString!.toLower
`(class $Class:ident.{u} (α : Type u) where
$field:ident : α
instance {α} [$Class α] : OfNat α (nat_lit $n) where
ofNat := $Class α.1
instance {α} [OfNat α (nat_lit $n)] : $Class α where
$field:ident := $n)
ofNat_class Zero 0