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

feat: support constructor arguments given as explicit binders #18

Merged
merged 5 commits into from
Jun 25, 2024

Conversation

Equilibris
Copy link
Collaborator

@Equilibris Equilibris commented Jun 24, 2024

closes #11

@Equilibris Equilibris requested a review from alexkeizer as a code owner June 24, 2024 13:24
@Equilibris Equilibris force-pushed the feat-11-alt-binders branch from 8ef357b to 9b34c8f Compare June 24, 2024 13:25
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
Copy link
Collaborator Author

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

Suggested change
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

@Equilibris Equilibris changed the title gsfeat: Fix binder issue feat: Fix binder issue Jun 24, 2024
@Equilibris Equilibris enabled auto-merge June 24, 2024 15:07
Comment on lines 543 to 545
/- Transforms binders into simple lambda types. -/
let view ← dataSyntaxToView modifiers decl
let view ← preProcessCtors view /- same as >>= -/
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/- 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

Comment on lines 147 to 153
-- 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
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alexkeizer alexkeizer changed the title feat: Fix binder issue feat: allow binders in constructor definitions Jun 25, 2024
@alexkeizer alexkeizer changed the title feat: allow binders in constructor definitions feat: support constructor arguments given as explicit binders Jun 25, 2024
Copy link
Owner

@alexkeizer alexkeizer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Equilibris Equilibris merged commit 2093eb4 into master Jun 25, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature: support constructor arguments given as binders
2 participants