meander

All things about https://github.com/noprompt/meander Need help and no one responded? Feel free to ping @U5K8NTHEZ
noprompt 2020-11-24T18:55:06.396700Z

((finder '{?k ?v} identity) {:a 1 :b 2})
;; =>
{?k :a, ?v 1}

((searcher '{?k ?v} identity) {:a 1 :b 2})
;; =>
({?k :a, ?v 1} {?k :b, ?v 2})

noprompt 2020-11-24T18:57:11.398400Z

There are details about the implementation in the comments but the gist here is that there is a framework for building up pattern matchers functionally. For now, this framework is largely private and only REPL tested and approved.

noprompt 2020-11-24T18:59:16.400400Z

The reason it is private is because 1. there are no unit tests, 2. there is no interpretation for substitution, and 3. pending the substitution interpretation I may want to move things around.

noprompt 2020-11-24T19:03:27.402900Z

What is nice, however, is that this model is pretty flexible and once the second items is taken care of and things can be made public, more interesting runtimes can be developed.

noprompt 2020-11-24T19:07:59.404100Z

$ bb --classpath src
Babashka v0.2.3 REPL.
Use :repl/quit or :repl/exit to quit the REPL.
Clojure rocks, Bash reaches.

user=> (require '[meander.interpreter.epsilon :as m])
nil
user=> (m/searcher '{?k ?v} identity)
#object[sci.impl.fns$eval_fn$fn__12966 0x5212d6ab "sci.impl.fns$eval_fn$fn__12966@11052c160"]
user=> (*1 {:a 1 :b 2 :c 3})
({?k :c, ?v 3} {?k :b, ?v 2} {?k :a, ?v 1})
user=> (m/finder '{?k ?v} identity)
#object[sci.impl.fns$eval_fn$fn__12966 0x62700f6 "sci.impl.fns$eval_fn$fn__12966@1109c9048"]
user=> (*1 {:a 1 :b 2 :c 3})
{?k :c, ?v 3}

👍 3
noprompt 2020-11-24T19:09:36.405500Z

The runtime bit is nice. Both searcher and finder use the same factory functions to build up an über factory which takes a runtime and produces a implementation specific matching function.

noprompt 2020-11-24T19:10:17.406400Z

In the case of searcher it produces a sequence of results; with finder it reduces the space down to the first one it finds. The details are in the runtime.

noprompt 2020-11-24T23:13:12.407700Z

Before I merge, cut, and release, I need to add some unit tests for the interpreter namespace.

❤️ 1