-
Notifications
You must be signed in to change notification settings - Fork 4
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
feat: support constructor arguments given as explicit binders #18
Conversation
8ef357b
to
9b34c8f
Compare
Qpf/Macro/Data/Replace.lean
Outdated
def preProcessCtors (view : DataView) : m DataView := do | ||
let ctors ← view.ctors.mapM fun ctor => do | ||
let namedArgs ← ctor.binders.getArgs.mapM getBinderNamesAndType | ||
let flatArgs: Array (TSyntax `term) := (namedArgs.map (fun (ids, ty) => ids.map (fun _ => ⟨ty⟩))).flatten.reverse |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make code a bit more succinct
let flatArgs: Array (TSyntax `term) := (namedArgs.map (fun (ids, ty) => ids.map (fun _ => ⟨ty⟩))).flatten.reverse | |
let flatArgs : Array Term := | |
(namedArgs.map (fun (ids, ty) => ids.map (fun _ => ⟨ty⟩))) | |
|>.flatten.reverse |
Qpf/Macro/Data.lean
Outdated
/- Transforms binders into simple lambda types. -/ | ||
let view ← dataSyntaxToView modifiers decl | ||
let view ← preProcessCtors view /- same as >>= -/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/- Transforms binders into simple lambda types. -/ | |
let view ← dataSyntaxToView modifiers decl | |
let view ← preProcessCtors view /- same as >>= -/ | |
let view ← dataSyntaxToView modifiers decl | |
let view ← preProcessCtors view -- Transforms binders into arrow types |
Qpf/Macro/Data/Replace.lean
Outdated
-- Have a look at how, e.g., def, deals with binders, | ||
-- this method might already exist look for BinderView | ||
def getBinderNamesAndType : Syntax → m (Array Syntax × Syntax) | ||
| .node _ `Lean.Parser.Term.explicitBinder | ||
#[_, (.node _ `null ids), (.node _ `null #[_, ty]), _, _] => | ||
pure (ids, ty) | ||
| _ => Elab.throwUnsupportedSyntax |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
closes #11