This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-01-20
Channels
- # announcements (9)
- # aws-lambda (5)
- # babashka (26)
- # beginners (200)
- # bristol-clojurians (2)
- # calva (74)
- # cider (22)
- # clj-kondo (8)
- # cljsrn (1)
- # clojure (124)
- # clojure-australia (2)
- # clojure-europe (79)
- # clojure-spec (1)
- # clojure-uk (37)
- # clojurescript (87)
- # cloverage (1)
- # code-reviews (10)
- # conjure (41)
- # cursive (5)
- # datahike (2)
- # datascript (3)
- # datomic (11)
- # docker (4)
- # duct (1)
- # emacs (10)
- # events (1)
- # fulcro (3)
- # graalvm (1)
- # honeysql (3)
- # jobs (1)
- # malli (12)
- # meander (51)
- # off-topic (83)
- # pathom (28)
- # quil (3)
- # reagent (19)
- # reitit (3)
- # releases (1)
- # shadow-cljs (49)
- # spacemacs (2)
- # sql (5)
- # startup-in-a-month (1)
- # testing (1)
- # xtdb (8)
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
.
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"]]]]
So something that could also be going on here is the the value at :values
is not a vector?
(I’m laughing because Jimmy and I have the tendency to simulreply with pretty much the same answers/suspicions.)
Maybe put in an (m/app type !titles)
and see.
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?
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.
Cool. Just turn my gibberish into something that makes sense to the general population. 😛
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.
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 do think we’ve been up front about that in particular. That ()
means seq?
[]
means vector?
etc.
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.
And he did teach me a new trick today. I would have lol done it by hand in Clojure. Pretty nifty trick.
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!