Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

属性紹介: @[class] 属性 #309

Open
Seasawher opened this issue Jun 19, 2024 · 1 comment
Open

属性紹介: @[class] 属性 #309

Seasawher opened this issue Jun 19, 2024 · 1 comment
Labels

Comments

@Seasawher
Copy link
Member

see: https://leanprover.zulipchat.com/#narrow/stream/113489-new-members/topic/what.20is.20.60class.60.20attribute/near/445581181

MIL の7章に記述があるものの,ただの構造体との違いがわからない

@Seasawher
Copy link
Member Author

Seasawher commented Jun 19, 2024

variable {α : Type}

@[class] structure One (α : Type) where
  one : α

instance instOneNat : One Nat where
  one := 1

structure Two (α : Type) where
  two : α

instance instTwoNat : Two Nat where
  two := 2

example {T : Type} [One T] : True := by trivial

/--
error: invalid binder annotation, type is not a class instance
  Two T
use the command `set_option checkBinderAnnotations false` to disable the check
-/
#guard_msgs in example {T : Type} [Two T] : True := by trivial

#synth One Nat

/--
error: type class instance expected
  Two Nat
-/
#guard_msgs in #synth Two Nat

@Seasawher Seasawher changed the title @[class] 属性の謎 属性紹介: @[class] 属性 Jun 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant