Fork me on GitHub
#meander
<
2020-07-18
>
ikrimael00:07:56

@jatkin care to share insight?

JAtkins00:07:41

Not much, just I now understand the syntax extensions. Made a pseudo xor which works well.

JAtkins00:07:25

Still confused about _ though. If there is a more detailed explanation Iโ€™d greatly appreciate it ;)

ikrimael00:07:46

probably would be useful to others still (maybe in the examples doc?) I find myself in the same pattern: struggling with the syntax and "i get it" nirvana when i figure it out

Jimmy Miller00:07:54

I hope to find time to go back and make a thorough explanation of the things you've run into. Just been a busy few days.

Jimmy Miller00:07:02

_ just matches anything.

JAtkins00:07:13

Even an empty space I guess?

Jimmy Miller00:07:27

_ ... Means zero or more of anything.

๐Ÿ‘ 3
Jimmy Miller00:07:31

So that would include nothing.

Jimmy Miller00:07:54

That is also why your ?x ... Wasn't working. Because what can we bind ?x to when it matches nothingness?

๐Ÿ‘ 3
JAtkins00:07:00

Huh. I would expect _ to bind to something at least. Good to know though.

Jimmy Miller00:07:33

It would, if you didn't say the ... It is like .* in regex

Jimmy Miller00:07:09

You can say ..1 to do at least one element.

JAtkins00:07:35

Ah, I had a very bad misconception. I thought ... would match nothing. Instead it is a postfix modifier.

JAtkins00:07:56

[...] is invalid syntax.

Jimmy Miller00:07:59

Yep exactly right.

JAtkins18:07:00

haha, I went to make a note about ... being a postfix operator, and it was already there. Not sure how I missed it the first time. I may have just skimmed that section initially since I thought "of course I know what ... does, I use it all the time" ๐Ÿ™‚

JAtkins00:07:17

Bingo, thank you very much for that!

Jimmy Miller00:07:07

It repeats everything till the end or until it hits a dot. [1 . 2 ...] would match a vector with just a one in it. Or a vector with a 1 followed by a bunch of 2s.

Jimmy Miller00:07:54

No problem. There is definitely some conceptualizing that has to go on. I struggled quite a bit with meander when Joel first introduced me to it.

noprompt00:07:26

If itโ€™s worth anything I have mixed feelings about the syntax myself. I pulled inspiration from many places. The โ€ฆ I borrowed from Racket but I tweaked it a little bit.

noprompt00:07:30

Iโ€™m close to having a search interpreter ready for folks to use.

noprompt00:07:52

(let [map-search (make-search-fn '{?k ?v :as ?m & ?rest})]
  (map-search {:a 1 :b 2 :c 3}))
;; =>
'({?m {:a 1, :b 2, :c 3}, ?k :a, ?v 1, ?rest {:b 2, :c 3}}
  {?m {:a 1, :b 2, :c 3}, ?k :b, ?v 2, ?rest {:a 1, :c 3}}
  {?m {:a 1, :b 2, :c 3}, ?k :c, ?v 3, ?rest {:a 1, :b 2}})

noprompt00:07:38

This is one of the places where if you were attempting to construct a pattern involving ... itโ€™d be unpleasant.

noprompt00:07:36

But I think this is one of the last contributions I want to make to epsilon and then get back to zeta.

๐Ÿ‘Œ 6
ikrimael03:07:52

I think the challenge I'm having is somewhat "curse of its own success"

ikrimael03:07:41

a lot of times, it looks like magic/i don't have a high level mental model of how it's implemented

ikrimael03:07:11

so finding myself resorting to rote memorization of syntax/grammar

JAtkins18:07:52

Yup. I have the same issue. I'm starting to think I'll just need to read the source code to see why it does what it does. Right now all I can say is "magic happens" whenever one of these is compiled. Makes it very hard in more advanced use cases to back out what I should do to get the result I want.

Jimmy Miller21:07:49

For me learning meander was more akin to learning functional programming than it was for learning aom clojure library. My recommendation is not try to think about what something does or how it compiles but think about what it means. For example a logic variable is bound to one and only one value. It cannot be rebound. It also must be bound for a match to be valid. Given this, if I see two mentions of the same logic variable, I know they are bound to the same value. So I can use logic variables to join. Same thing is true with the top level API of meander. Match accepts a singular deterministic pattern. Search allows for ambiguity and finds all values that satisfy the match. How all these things work isn't something that I thought about. Just like I never thought about how closures work, or how algebraic data types work. I just think about what they are. What properties they have.

JAtkins21:07:20

Maybe that's up to learning differences? I typically do better using a tool if I can "see" under the hood. I use see loosely as a stand in for "I kind of know how this works, and if I needed to I could write it". I'll definitely try approaching it as learning a top level thing first though. Understanding the code in meander would take quite a while ๐Ÿ™‚

Jimmy Miller21:07:23

Yeah epsilon is not an easy codebase to understand because it was built while exploring the problem. But also because it just does a lot and is complicated. I did try to explain how we are making zeta. https://jimmyhmiller.github.io/building-meander-in-meander Understanding how meanders actual compiler works would probably not help many people. But I do think understanding a straw man interpreter can be very useful.

๐Ÿ‘ 3