Fork me on GitHub
#meander
<
2022-05-05
>
wilkerlucio01:05:58

this sounds to me a lot like the work I do on Pathom, which covers the case for schema evolution, you can always make resolvers to allow both old and new names to work together 🙂 have you checked #pathom @U0P7M2VHR?

wilkerlucio02:05:27

just for fun, I re-created the Cambria todo demo using Pathom 3: https://gist.github.com/wilkerlucio/ca2628616ea8bf42e24169f02b9c30a5

noprompt04:05:05

Lenses are one of those "great in theory, not in practice" things IMO. 🙂

nivekuil04:05:34

specter is the clojure lens library, and indeed for me confirm pathom + meander crowds out its uses 95% of the time

Danny04:05:44

This video is quite a bit different though. Bi-directional, middleware on top of an event log.

Danny04:05:21

Just the yaml would be so much nicer to replace with meander expression that works both directions.

nivekuil04:05:34

￱*￱ specter is the clojure lens library, and indeed for me pathom + meander crowds out its uses 95% of the time

Danny20:05:14

Is there something like [_ ... true _ . (m/pred string? !s) ..1 (m/or false $)] where $ is like regex end-of-line (end of seq/vector) in meander? I couldn’t find it 🤷

Danny20:05:13

Basically how to match something followed by something specific, or nothing at all

noprompt21:05:54

The end would be

[& _ _END]
(BTW _ is a prefix for wildcards _<suffix> )

noprompt21:05:58

I think you are trying to say the end can be false?

noprompt21:05:05

[& _ true _ . (m/pred string? !s) ..1 & (m/or [false] [])]

noprompt21:05:47

Because <pattern> in & <pattern> is applied to the sequence

noprompt21:05:16

And, FWIW, you can use & _ as a substitute for _ ...

noprompt21:05:19

[& _ true _ & [(m/pred string? !s) ..1] & (m/or [false] [])]

noprompt21:05:43

Some where there is a true followed by another object followed by 1 or more strings end the end of the sequence is either [false] or [] (because we consumed everything)

noprompt21:05:52

Is that correct?

Danny22:05:36

Let me try

Danny22:05:22

(def input [1  2 true  3 "foo" "bar"  4  5 "not after thing"  6  true  34 "more" "text" "thing"  4  5])

(m/search input [& _ true _ & [(m/pred string? !s) ..1] & (m/or [(m/pred (complement string?))] [])] !s)

=> ()

Danny22:05:58

Trying to get (["foo" "bar"] ["more" "text" "thing"])

Danny22:05:06

(m/search input  [& _ true _ & [(m/pred string? !s) ..1] & (m/or [(m/pred (complement string?)) & _] [])] !s)
=>
(["foo" "bar"] ["more" "text" "thing"])

Danny22:05:22

Ok so & creates a new sequence of the rest, of course 😄 … nice

Danny22:05:16

Is there any “efficiency” difference between the tail sequence matching, or “inline” matching?

(m/search input  [_ ... true _ . (m/pred string? !s) ..1 & (m/or [(m/pred (complement string?)) . _ ...] [])] !s)
also works, but I need & for the m/or to work

Danny01:05:53

@U06MDAPTP do you expect any performance difference? Or is the rewrite going to change everything? 😄

noprompt14:05:56

Well, the goal is to eventually exceed the current level of performance in many situations, however, at the moment I've only been focused on building out the most basic implementation of the semantics. The basic implementation is an interpreter and I'm very close to having it finished. Once that is done, work will start on optimizing that by using simplification (aka rewriting rules). After that, the then moving on to a compiler, probably doing something staged, would be next.

clojure-spin 1
noprompt14:05:14

The zeta-0 branch does staged compilation and produces very nice code in many situations. The problem was that the compiler was too slow to be suitable for a macro. Also, in some cases debugging was a bit difficult. I could have a suite a of passing tests that showed that all the basic parts were working correctly but I would encounter unexpected interaction behavior between those parts.

noprompt14:05:59

So now, I'm starting from "dumb".

Danny22:05:18

Well this is good to know!

user=> (m/search (vec "ayo nopromptz") [!first & _ !last] [!first !last])

([[\a] [\z]])

Danny22:05:11

I don’t really get it yet though:

(m/search (vec "ayo nopromptz") [?first & [_ ..1 ?last] ?last2] [?first ?last ?last2])

([\a \t \z])

Danny22:05:08

So the first vector directly after & can match, and then more can follow outside the vector that basically terminates the in-vector match earlier 🤯 (because ?last becomes \t and not \z )

Danny22:05:03

This even more confusing

user=> (m/search (vec "ayo nopromptz") [?first & [_ ..1 \y \o \space \n \o \p \r \o \m \p ?last] ?last2] [?first ?last ?last2])

([\a \t \z])
but
user=> (m/search (vec "ayo nopromptz") [?first & [_ ... \a \y \o \space \n \o \p \r \o \m \p ?last] ?last2] [?first ?last ?last2])

nil

Danny22:05:57

a is captured in ?first but then _ ..1 still matches! But when a is captured in ?first it’s not available in & [_ ... \a \y \o

Danny22:05:02

What character (?) is the _ in [_ ..1 \y \o ?

Danny22:05:50

Seems like a bug

(m/search (vec "ayo nopromptz") [?first & [_ ..1337 \y \o \space \n \o \p \r \o \m \p ?last] ?last2] [?first ?last ?last2])

([\a \t \z])

Danny22:05:38

String is not 1337 chars long 😄

Danny23:05:39

This works pretty much like expected

user=> (m/search (vec "ayo nopromptz") [?first & [_ \y \o \space \n \o \p \r \o \m \p ?last] ?last2] [?first ?last ?last2])
nil
user=> (m/search (vec "ayo nopromptz") [?first & [\y \o \space \n \o \p \r \o \m \p ?last] ?last2] [?first ?last ?last2])
([\a \t \z])

Danny23:05:16

Can I have more than 1 group after & :thinking_face: Yes!

(m/search
  (vec "ayo nopromptz")
  [?first
     & [\y \o \space]
     & [\n \o \p \r \o \m \p ?last]
   ?last2]
  [?first ?last ?last2])

=>
([\a \t \z])

noprompt23:05:28

Yah. There are some bugs. I've been slowly iterating on the next version of the library which starts from a much simpler, naïve base.