This upstreams NatCast and IntCast alone independent of norm_cast in #3322. This will allow more efficiently upstreaming parts of Std.Data.Int relevant for omega. --------- Co-authored-by: Scott Morrison <scott.morrison@gmail.com>
15 lines
430 B
Text
15 lines
430 B
Text
class Semiring (R : Type u) extends Add R, HPow R Nat R, Mul R where
|
|
zero : R
|
|
|
|
instance [Semiring R] : OfNat R n where
|
|
ofNat := Semiring.zero
|
|
|
|
def Nat.castTest [Semiring R] (n : Nat) : R := let _ := n = n; Semiring.zero
|
|
|
|
@[default_instance high] instance [Semiring R] : HPow R Nat R := inferInstance
|
|
|
|
instance [Semiring R] : CoeTail Nat R where
|
|
coe n := n.castTest
|
|
|
|
variable (R) [Semiring R]
|
|
#check (8 + 2 ^ 2 * 3 : R) = 20
|