lean4-htt/tests/pkg/deriving/UserDeriving/Simple.lean

22 lines
No EOL
659 B
Text
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import Lean
class Simple (α : Type u) where
val : α
open Lean
open Lean.Elab
open Lean.Elab.Command
def mkSimpleHandler (declNames : Array Name) : CommandElabM Bool := do
dbg_trace ">> mkSimpleHandler {declNames}"
-- TODO: see examples at src/Lean/Elab/Deriving
return true
def mkMyInhabitedHandler (declNames : Array Name) : CommandElabM Bool := do
for declName in declNames do
let cmd ← `(def $(mkIdent (declName ++ `test)) := 0)
elabCommand cmd
return false -- `false` instructs Lean to run the next handler
initialize
registerDerivingHandler ``Simple mkSimpleHandler
registerDerivingHandler ``Inhabited mkMyInhabitedHandler