lean4-htt/tests/lean/defaultInstanceWithPrio.lean
2022-10-19 09:28:08 -07:00

13 lines
272 B
Text

structure Rational where
num : Int
den : Nat
inv : den ≠ 0
@[default_instance 200]
instance : OfNat Rational n where
ofNat := { num := n, den := 1, inv := by decide }
instance : ToString Rational where
toString r := s!"{r.num}/{r.den}"
#check 2 -- Rational