Am I going insane or is this not acting right. (Sorry for the large splat of code with probably horrible indentation.)
xyz.core> x
{:class :org.commonmark.node.Document,
:children
({:class :org.commonmark.ext.front.matter.YamlFrontMatterBlock,
:children
({:children (),
:key "Title",
:values ["Meta title"],
:class :org.commonmark.ext.front.matter.YamlFrontMatterNode})})}
xyz.core> (meander/find x
{:class :org.commonmark.node.Document
:children (_ ... {:class :org.commonmark.ext.front.matter.YamlFrontMatterBlock
:children (_ ... . {:class :org.commonmark.ext.front.matter.YamlFrontMatterNode
:key "Title"
:values [!title ...]
} . _ ...)} . _ ...)}
[:html [:head [:title !title]]])
nil
xyz.core> (meander/find x
{:class :org.commonmark.node.Document
:children (_ ... {:class :org.commonmark.ext.front.matter.YamlFrontMatterBlock
:children (_ ... . {:class :org.commonmark.ext.front.matter.YamlFrontMatterNode
:key "Title"
:values !title
} . _ ...)} . _ ...)}
[:html [:head [:title !title]]])
[:html [:head [:title [["Meta title"]]]]]
Look at the :values
piece of the pattern. For some reason, [!title …]
doesn’t match a vector of strings and pick up each string, but !title
does match the whole vector. Is that right? What am I missing?
But this works as expected in the small:
xyz.core> (meander/find {:values ["Meta title"]}
{:values [!title ...]} !title)
["Meta title"]
Literally, the only difference between the first two cases, above, is the :values [!title …]
vs. :values !title
.
Taking a look
Hmm… I’m curious that you get nil
because when I tried this at the REPL I get
(let [x '{:class :org.commonmark.node.Document,
:children
({:class :org.commonmark.ext.front.matter.YamlFrontMatterBlock,
:children
({:children (),
:key "Title",
:values ["Meta title"],
:class :org.commonmark.ext.front.matter.YamlFrontMatterNode})})}]
(me/find x
{:class :org.commonmark.node.Document
:children (_ ... {:class :org.commonmark.ext.front.matter.YamlFrontMatterBlock
:children (_ ... . {:class :org.commonmark.ext.front.matter.YamlFrontMatterNode
:key "Title"
:values [!title ...]}
. _ ...)}
. _ ...)}
[:html [:head [:title !title]]]))
;; =>
[:html [:head [:title ["Meta title"]]]]
Yea, I don’t get it either.
Is it actually a vector? Or some other type?
So something that could also be going on here is the the value at :values
is not a vector?
Hahah
OK, that works as expected in my REPL, too. I just cut/pasted your text
(I’m laughing because Jimmy and I have the tendency to simulreply with pretty much the same answers/suspicions.)
I’m gonna let him type. 🙂
Maybe put in an (m/app type !titles)
and see.
Ah. Nope, it’s a java.util.ArrayList
But it prints as a vector. Grrrrr…
You could use m/seqable
there.
Yeah. It is very annoying the printer does that.
OK, so this is a key thing for the documentation.
You still need to get back to me about m/seqable
and whether we’re documenting it or not. 🙂
Ah, yeah, sorry I’ve been just busy. Maybe just hit me/the channel with question about it daily or something?
But yes, m/seqable
should have a docstring.
What does it do?
Or be documented. Essentially it matches the any seqable?
thing with the remaining arguments being the same as those you would stick between []
or ()
.
Example
(m/or [1 2 3 . !x !y ...] (1 2 3 . !x !y ...))
;;
(m/seqable 1 2 3 . !x !y ...)
Both. It needs a docstring for docs at the REPL. But also it needs more expansive coverage in the manual.
OK, gotcha.
Cool. Just turn my gibberish into something that makes sense to the general population. 😛
Ha!
Alright, I get it.
This is actually good, exploring some of the corner cases.
I just used m/seqable
and it worked great.
I’ve had a similar issue before, using []
in the pattern when I was matching a seq/list, and didn’t realize. It’s definitely one of those fine points.
It’s the big difference in philosophy from, say, core.match
.
I never liked [x y z :seq]
or whatever the grossness was.
Yea, I’m OK with how it works in Meander. Just need to get it documented so that it doesn’t trip up others.
I was pulling my hair out for about 45 minutes before I posted here.
I do think we’ve been up front about that in particular. That ()
means seq?
[]
means vector?
etc.
Ah, bummer! 😞
Yea, no biggie. It’s just a key point that needs to be hammered home.
I’ll make sure it receives some coverage in the manual.
Well, definitely yelp for help next time and keep your hair. 🙂
Also, this wasn’t Meander’s issue. It’s really an issue with the Clojure printer sort of glossing over the difference between vectors and Clojure arrays.
If it something definitely seems like it should work and it doesn’t it’s either a bug or something else is going on.
Yeah. I had this problem dealing with XML stuff before.
@jimmy gets the award for the day.
He’s an award winning guy. 😄
He beat you by 3 seconds.
And he did teach me a new trick today. I would have lol done it by hand in Clojure. Pretty nifty trick.
I gotta get up and start making dinner. BBL
Yea, exactly. I was starting to write it by hand in Clojure with multimethods, which would have been fine, but I say, “Wait a second, Meander rocks at term rewriting. I should use that! And it’ll help me with my Meander fu.” And then I spent a whole bunch of time messing with it and trying to get it to work. Doh!