meander

All things about https://github.com/noprompt/meander Need help and no one responded? Feel free to ping @U5K8NTHEZ
timothypratley 2020-01-07T00:57:47.290400Z

I started a new page: https://github.com/noprompt/meander/wiki/How-To with the intention of allowing people to contribute little snippets that demonstrate putting meander concepts into practice

3šŸ‘2šŸ‘
aisamu 2020-01-07T12:08:55.004Z

Yup, works - but it's worth noting that, like the wiki, I'd still probably wouldn't add to it without consulting this channel first!

ingesol 2020-01-07T13:15:19.004400Z

@timothypratley Had a look at it now. Exactly the kind of thing I need, thanks! Would prefer if all examples also included output though.

1šŸ‘
2020-01-07T14:32:41.004600Z

This is awesome! I'd like to recommend erring on the side of too many examples rather than too few. On the one hand, having tons of examples makes it difficult to keep them up-to-date as the library evolves. But on the other hand, with Meander, I typically spend the 80% of my time on the one or two transformations that aren't obvious, so having a large library of examples to scan could really cut down on that time and improve efficiency for new users (might also help @noprompt and @jimmy distill best practices/steer the library). Thoughts?

jimmy 2020-01-07T14:49:23.004800Z

Yeah feel free to make as many changes as you'd like. I plan on contributing some. We can review things if there isn't anything that isn't recommended. But for a cookbook the more you can add the better.

timothypratley 2020-01-07T00:59:36.290600Z

I think if we can collect a lot of use cases it will help funnel people to the right concepts to explore. I know that I often have a ā€œgoalā€ in mind where Iā€™m not sure what primitives I need to draw on.

1ā˜ļø
timothypratley 2020-01-07T01:01:13.290800Z

Iā€™ve never really set up a github wiki before so Iā€™d like to knowā€¦ can everyone edit this or only ā€œblessedā€ contributors? Iā€™m hoping everyone because that was the idea.

aisamu 2020-01-07T01:10:54.291200Z

@timothypratley only "blessed" contributors! (confirmed while logged in)

timothypratley 2020-01-07T01:13:29.291500Z

Regarding ā€œduplicationā€ā€¦ I would have expected the solution in this case be be:

(m/rewrite [[:a 1] [:b 2] [:c 3]]
           [[!k !n] ...]
           [(m/let [?n !n]
                   [!k ?n (m/app str ?n)]) ...])

timothypratley 2020-01-07T01:14:23.291700Z

i.e. if I want to access !n once and use it twice, let seems like the tool. But ā€¦ like most of my made up solutionsā€¦ it doesnā€™t work.

timothypratley 2020-01-07T01:15:10.291900Z

Is there a way to do this?

timothypratley 2020-01-07T01:16:07.292100Z

Ah damn, any suggestions on a more contribution friendly medium? @aisamu thank you for trying it.

timothypratley 2020-01-07T01:24:18.292500Z

@noprompt or @jimmy can you open this up following these instructions: https://help.github.com/en/github/building-a-strong-community/changing-access-permissions-for-wikis please? (assuming you are O.K. with allowing anyone to edit šŸ™‚ )

jimmy 2020-01-07T01:26:07.292700Z

I don't have permissions either. Up to Joel.

noprompt 2020-01-07T01:30:55.292900Z

@timothypratley I would prefer not to use the Github Wiki.

timothypratley 2020-01-07T01:31:15.293100Z

ah ok no problem

noprompt 2020-01-07T01:32:31.293300Z

@timothypratley Sorry, I hit enter before I could finish my thoughtā€¦ I would prefer to have everything documentation/tutorial related checked in under the doc/ folder. I donā€™t like having multiple sources of docs, etc.

timothypratley 2020-01-07T01:32:56.293500Z

Yeah, how about doc/HOWTO.md for now?

noprompt 2020-01-07T01:33:18.293700Z

Sure, thats perfectly fine with me.

timothypratley 2020-01-07T01:33:21.293900Z

Iā€™m thinking if itā€™s just a receipy book people will feel more empowered to add to it than a tutorial

timothypratley 2020-01-07T01:33:43.294100Z

and you can submit a PR from the github editor pretty easily so honestly not much different from a wiki

noprompt 2020-01-07T01:33:54.294300Z

The examples/ folder is another nice place.

noprompt 2020-01-07T01:34:07.294500Z

For REPL like stuff, yes, please put that in a Cookbook.md kinda thing.

noprompt 2020-01-07T01:34:54.294700Z

Iā€™m not a fan of the Wiki pages because they tend to get out of sync with the project no matter how good peopleā€™s intentions are.

timothypratley 2020-01-07T01:35:27.294900Z

OK, Iā€™ll make a PR

noprompt 2020-01-07T01:35:34.295100Z

Also, its nice to be able to clone the repository and have all of that stuff come down with it.

timothypratley 2020-01-07T01:35:46.295300Z

yeah for sure!

jimmy 2020-01-07T01:35:47.295500Z

Yeah cookbook.md would be good. We can merge things pretty easily for that.

timothypratley 2020-01-07T01:42:17.295700Z

@noprompt it seems I can create the wiki but not destory it hahaha so just letting you know I have the text, please nuke it šŸ™‚

timothypratley 2020-01-07T06:13:19.000100Z

To close out this thread; the new location is https://github.com/noprompt/meander/blob/epsilon/doc/cookbook.md ^^ @aisamu it would be great if you could try the Github ā€œedit this fileā€ and confirm that that is ā€œreasonably convenientā€ or at least works?

1šŸ‘
noprompt 2020-01-07T06:47:21.000400Z

(me/search '[a b c d e f g]
 (me/and [!xs ..?i !ys ..?j !zs ..?k]
         (me/guard (and (< ?i ?j)
                        (< ?k ?j))))
  [!xs !ys !zs])
;; =>
([[] [a b c d] [e f g]]
 [[] [a b c d e] [f g]]
 [[] [a b c d e f] [g]]
 [[] [a b c d e f g] []]
 [[a] [b c d e] [f g]]
 [[a] [b c d e f] [g]]
 [[a] [b c d e f g] []]
 [[a b] [c d e] [f g]]
 [[a b] [c d e f] [g]]
 [[a b] [c d e f g] []]
 [[a b c] [d e f g] []])
ā˜ļø Using the example as reference. Note that the search results include the solution given by the example.

1šŸ‘€
noprompt 2020-01-07T06:52:42.003800Z

I thought this was fun enough to share:

[?v ?x (m/and ?m (m/or {?x ?v} {?x _ & ?m}))]
The value of ?x is ?v or ?x is not in the map ?m.

aisamu 2020-01-07T17:47:21.008300Z

> & ?m :as ?m Is the ?m being overwritten? (i.e. is "collect the rest into ?m, but then rebind the whole map as ?m" a correct reading ?) (I tried it on a REPL but got: Every pattern of an or pattern must have references to the same unbound logic variables.)

noprompt 2020-01-07T18:24:47.008600Z

No, the ?m is not being overwritten. Logic variables are only unbound/rebound by backtracking. But I realize now I took my example out of context so let me fix that. šŸ™‚

1šŸ‘
noprompt 2020-01-07T18:27:48.008900Z

(m/rewrite [1 'x {'x 0}]
  [?v ?x (m/and ?m (m/or {?x ?v} {?x _ & ?m}))]
  ?m)
;; => nil

(m/rewrite [1 'x {'x 1}]
  [?v ?x (m/and ?m (m/or {?x ?v} {?x _ & ?m}))]
  ?m)
;; => {'x 1}

(m/rewrite [1 'x {}]
  [?v ?x (m/and ?m (m/or {?x ?v} {?x _ & ?m}))]
  ?m)
;; => {}

aisamu 2020-01-07T23:20:12.009200Z

That makes way more sense, thanks!

aisamu 2020-01-07T12:08:55.004Z

Yup, works - but it's worth noting that, like the wiki, I'd still probably wouldn't add to it without consulting this channel first!

ingesol 2020-01-07T13:15:19.004400Z

@timothypratley Had a look at it now. Exactly the kind of thing I need, thanks! Would prefer if all examples also included output though.

1šŸ‘
2020-01-07T14:32:41.004600Z

This is awesome! I'd like to recommend erring on the side of too many examples rather than too few. On the one hand, having tons of examples makes it difficult to keep them up-to-date as the library evolves. But on the other hand, with Meander, I typically spend the 80% of my time on the one or two transformations that aren't obvious, so having a large library of examples to scan could really cut down on that time and improve efficiency for new users (might also help @noprompt and @jimmy distill best practices/steer the library). Thoughts?

jimmy 2020-01-07T14:49:23.004800Z

Yeah feel free to make as many changes as you'd like. I plan on contributing some. We can review things if there isn't anything that isn't recommended. But for a cookbook the more you can add the better.

2020-01-07T15:02:18.005800Z

So, in ref to https://github.com/noprompt/meander/issues/106, how does rewrite's arity work? I thought it had to be an even arity, but @timothypratley showed an example of an odd arity.

jimmy 2020-01-07T15:04:45.006Z

We don't have a substitute version of let yet. You can do this, or duplicate the memory variable with (m/and !n !n2)

(m/match [[:a 1] [:b 2] [:c 3]]
  [[!k !n] ...]
  (let [?n !n]
    (m/subst
      [[!k ?n (m/app str ?n)] ...])))

jimmy 2020-01-07T15:25:31.006700Z

Replied to the issue. Will work on expanding some docstrings and docs if I can find time today.

2020-01-07T15:26:45.006900Z

Aaaah, that explains my confusion.

jimmy 2020-01-07T15:32:46.007200Z

If you look at Tims example, he calls strategy m, not the main namespace. I've usually called it r. But it should maybe have a better name? r was Joel's go to for a while. I think I was the one use started using m for meander. r stood for rewrite. Ultimately, we should have better standard aliases, but this is a problem in the clojure community in general. Is clojure.string s or str or string? Example: https://clojurians.slack.com/archives/CFFTD7R6Z/p1577902861109300

2020-01-07T15:35:23.007500Z

Yeah, it's tricky. But I'm sure patterns will emerge over time.

timothypratley 2020-01-07T16:33:02.007700Z

Sorry for the confusion; Iā€™m not sure what the ā€œstandardā€ is or should be but I propose maybe strategy/rewrite and m/rewrite is also worth considering as ā€œmost stuff is in mā€

timothypratley 2020-01-07T16:33:46.007900Z

I would use meander/rewrite except that then I have to write meander/$ etc for ops

timothypratley 2020-01-07T16:35:59.008100Z

Iā€™d rather write $ hahahaha

aisamu 2020-01-07T17:47:21.008300Z

> & ?m :as ?m Is the ?m being overwritten? (i.e. is "collect the rest into ?m, but then rebind the whole map as ?m" a correct reading ?) (I tried it on a REPL but got: Every pattern of an or pattern must have references to the same unbound logic variables.)

noprompt 2020-01-07T18:24:47.008600Z

No, the ?m is not being overwritten. Logic variables are only unbound/rebound by backtracking. But I realize now I took my example out of context so let me fix that. šŸ™‚

1šŸ‘
noprompt 2020-01-07T18:27:48.008900Z

(m/rewrite [1 'x {'x 0}]
  [?v ?x (m/and ?m (m/or {?x ?v} {?x _ & ?m}))]
  ?m)
;; => nil

(m/rewrite [1 'x {'x 1}]
  [?v ?x (m/and ?m (m/or {?x ?v} {?x _ & ?m}))]
  ?m)
;; => {'x 1}

(m/rewrite [1 'x {}]
  [?v ?x (m/and ?m (m/or {?x ?v} {?x _ & ?m}))]
  ?m)
;; => {}

aisamu 2020-01-07T23:20:12.009200Z

That makes way more sense, thanks!