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

refactor: composition pipeline and qpf body parsing #19

Closed
wants to merge 2 commits into from

Conversation

Equilibris
Copy link
Collaborator

Have to discuss if the changes made to is_trivial are logically equivalent. Lots of use of bullet should be rewritten, this should probably be done together in the review to see the best way to write them. In some cases, there are bullet free versions below the line. Some changes to pattern matching, it might be worth modifying Comp.parseApp as well to allow for reuse of match results if this results in more readable code.

@Equilibris Equilibris requested a review from alexkeizer as a code owner June 25, 2024 11:51
@Equilibris
Copy link
Collaborator Author

Equilibris commented Jun 25, 2024

I also added some refactors for Replace in the same pr here, will be looking for more TODOs as well

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.

The diff is quite noisy and hard to review.
Generally, when doing big refactors, it's best to not move around and change code at the same time.

In this case, could you first submit a PR that takes the current code, and just copies it exactly into separate functions. That will have a large diff, but it should be relatively easy to confirm it's just moving code around and nothing semantically changed.

Then, in a second PR, make the semantic changes. That way, this second diff will be much more focussed, and it will be easier to see the relevant changes

Comment on lines +155 to +171
def Vector.mapM
{m : Type u → Type v}
{α : Type w}
{β : Type u}
[Monad m]
(l : Vector α n)
(f : α → m β) : m $ Vector β n :=
match l with
| ⟨.cons hd tl, b⟩ => do
let v ← f hd
let x ← Vector.mapM ⟨tl, by rfl⟩ f
pure ⟨v :: x.val, by {
rw [List.length_cons] at b
rw [List.length_cons, x.property]
exact b
}⟩
| ⟨.nil, h⟩ => pure ⟨[], by exact h⟩
Copy link
Owner

Choose a reason for hiding this comment

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

If Vector.mmap exists upstream, let's use that one

A general note on style:

  • We generally prefer putting variables on fewer lines, rather than getting a very tall definition
  • The type (and binders) should be indented one level more than the body of the definition
  • There's no need for { ... } around the multiline proof, by is white-space sensitive
  • rfl is also a term, there is (usually!) no need to use the tactic version (as in by rfl)
Suggested change
def Vector.mapM
{m : Type u → Type v}
{α : Type w}
{β : Type u}
[Monad m]
(l : Vector α n)
(f : α → m β) : m $ Vector β n :=
match l with
| ⟨.cons hd tl, b⟩ => do
let v ← f hd
let x ← Vector.mapM ⟨tl, by rfl⟩ f
pure ⟨v :: x.val, by {
rw [List.length_cons] at b
rw [List.length_cons, x.property]
exact b
}⟩
| ⟨.nil, h⟩ => pure ⟨[], by exact h⟩
def Vector.mapM {m : Type u → Type v}
{α : Type w} {β : Type u} [Monad m]
(l : Vector α n) (f : α → m β) : m $ Vector β n :=
match l with
| ⟨.cons hd tl, b⟩ => do
let v ← f hd
let x ← Vector.mapM ⟨tl, rfl⟩ f
pure ⟨v :: x.val, by simpa [List.length_cons, x.property] using b⟩
| ⟨.nil, h⟩ => pure ⟨[], by exact h⟩


private def CtorArgs.reset : ReplaceM m Unit := do
let r ← StateT.get
let n := r.vars.size
let ctor: CtorArgs := ⟨#[], (Array.range n).map fun _ => #[]⟩
StateT.set ⟨r.expr, r.vars, ctor
StateT.set { r with ctor }
Copy link
Owner

Choose a reason for hiding this comment

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

This seems like an unrelated change, please put that in it's own PR.
If you put the trivial stuff separately, I can quickly review and merge that, removing noise from the current diff

@Equilibris
Copy link
Collaborator Author

Closed in favour of #21 #22 and #23

@Equilibris Equilibris closed this Jun 26, 2024
@Equilibris Equilibris deleted the refactor-comp branch June 26, 2024 10:31
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.

2 participants