-
Notifications
You must be signed in to change notification settings - Fork 108
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: monadic defs for statically sized vectors #925
base: main
Are you sure you want to change the base?
feat: monadic defs for statically sized vectors #925
Conversation
WIP |
def modifyM [Monad m] (v : Vector α n) (i : Nat) | ||
(f : α → m α) : m (Vector α n) := do | ||
return ⟨←Array.modifyM v.toArray i f, | ||
by rw[←v.size_eq]; sorry⟩ |
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.
Any help in fixing this sorry
is welcome. I found a lemma by the name Array.size_modifyM
which however is not a straightforward equality.
-/ | ||
def mapM {α : Type u} {β : Type v} {m : Type v → Type w} [Monad m] | ||
(f : α → m β) (v : Vector α n) : m (Vector β n) := do | ||
return ⟨←Array.mapM f v.toArray, by rw[←v.size_eq]; sorry⟩ |
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.
This sorry
is also stuck for the same reason as the above comment because the corresponding Array API uses Satisfies. I am grateful for any help with these situations
def mapIdxM {α : Type u} {β : Type v} {m : Type v → Type w} [Monad m] | ||
(v : Vector α n) (f : Fin n → α → m β) : m (Vector β n) := do | ||
return ⟨←Array.mapIdxM v.toArray (v.size_eq.symm ▸ f), | ||
by rw[←v.size_eq]; sorry⟩ |
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.
Another sorry
that I am stuck at because the relevant API lemma uses the Satisfies
predicate.
This PR is the first follow up to #793. It adds all the monadic definitions for Vectors that correspond to similar definitions for Arrays in core and Batteries as well as defs which are immediately downstream of them. There are no plans to add theorems in this PR.
-[] Add all monadic definitions from
Init.Data.Array.Basic
and their downstream definitions for Vectors.-[] Add all monadic definitions from
Batteries.Data.Array.Basic
and their downstream definitions for Vectors.