-
Hello all! First off, thanks very much for I'm trying to use define_language! {
pub enum Nested {
One(Symbol),
"many" = Many(Vec<Id>),
}
} What's the best way to flatten a potential multi-layered
But I'm having trouble figuring out how to pull this off:
Any guidance would be greatly appreciated. Thanks again! Footnotes
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
Hi there! Yes, that is definitely one of the downsides of the variadic patterns: you can't write a pattern than captures all of them. You could maybe try refactoring to a sort of "cons list" approach, but I'm not sure if that would work in your domain. I think you could definitely do it in an analysis. I wouldn't fear cloning tooooo much, after all, you have to materialize the list somewhere. Perhaps a clever use of Rc or something a persistent vector could help. |
Beta Was this translation helpful? Give feedback.
-
Sure thing! One note: I would watch out for associativity, as it can
quickly explode the e-graph if you aren't careful. Maybe your usecase will
just work; but it's something to watch out for!
…On Thu, May 18, 2023 at 5:36 PM Graham ***@***.***> wrote:
Oh! Since “circuits” are lists of instructions to be applied in order and
gate operations form a group (sweeping details under the rug), I could have
a language entry
“seq” = Seq([Id; 2])
and add associativity as part of the rewrite rules.
Thanks so much again for your help and for the library!
—
Reply to this email directly, view it on GitHub
<#260 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AANTPTGAV6YAYERB4XYR25TXG26A5ANCNFSM6AAAAAAYG6UBGU>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
Hi there!
Yes, that is definitely one of the downsides of the variadic patterns: you can't write a pattern than captures all of them. You could maybe try refactoring to a sort of "cons list" approach, but I'm not sure if that would work in your domain. I think you could definitely do it in an analysis. I wouldn't fear cloning tooooo much, after all, you have to materialize the list somewhere. Perhaps a clever use of Rc or something a persistent vector could help.