lean4-htt/tests/lean/run/ofNat_class.lean

15 lines
421 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 <| 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