Zulip Chat Archive
Stream: new members
Topic: How to elable `deriving` for user defined type class
Asei Inoue (May 02 2024 at 00:04):
/-- user defined type class -/
class Callable (α : Type) where
call : α → String
/--
error: default handlers have not been implemented yet, class: 'Deriving.Callable' types: [Deriving.People]
-/
#guard_msgs in
deriving instance Callable for People
Asei Inoue (May 02 2024 at 00:05):
Can I define my own deriving
procedure for an arbitrary typeclass?
Kyle Miller (May 02 2024 at 00:06):
I think the only reference for that is to look at pre-existing derive handlers. You can search for registerDerivingHandler
in Lean and mathlib.
Adam Topaz (May 02 2024 at 00:07):
Here's the source for the handler for Nonempty
, for example: https://github.com/leanprover/lean4/blob/master/src/Lean/Elab/Deriving/Nonempty.lean
Adam Topaz (May 02 2024 at 00:07):
That folder has a few other examples.
Last updated: May 02 2025 at 03:31 UTC