Zulip Chat Archive

Stream: lean4

Topic: Derived/declared instance naming


Andrés Goens (Nov 26 2022 at 11:34):

I noticed that the deriving keyword when creating new types names instances differently from the instance keyword, putting the type before the instance type.

def NewNat := Nat deriving Inhabited
inductive NewNat2
  | zero : NewNat2
  | succ : NewNat2  NewNat2
instance : Inhabited NewNat2 where default := NewNat2.zero
#check instInhabitedNewNat2 -- declared instance
#check instNewNatInhabited -- derived instance

Not that it makes a big difference, but I was just curious: Is this deliberate to distinguish them?


Last updated: Dec 20 2023 at 11:08 UTC