This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-11-24
Channels
- # announcements (1)
- # asami (10)
- # aws (1)
- # babashka (1)
- # beginners (105)
- # cider (13)
- # cljsrn (6)
- # clojure (42)
- # clojure-australia (4)
- # clojure-dev (7)
- # clojure-europe (26)
- # clojure-nl (2)
- # clojure-uk (13)
- # clojurescript (19)
- # code-reviews (3)
- # conjure (18)
- # core-async (4)
- # core-matrix (5)
- # cryogen (3)
- # datomic (27)
- # depstar (21)
- # emacs (2)
- # figwheel-main (9)
- # fulcro (18)
- # helix (7)
- # jobs (3)
- # jobs-discuss (15)
- # juxt (7)
- # kaocha (4)
- # lambdaisland (2)
- # leiningen (11)
- # luminus (1)
- # malli (6)
- # meander (9)
- # minimallist (4)
- # mount (3)
- # off-topic (3)
- # pathom (8)
- # pedestal (28)
- # rdf (13)
- # re-frame (7)
- # reagent (5)
- # shadow-cljs (3)
((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})
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.
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.
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.
$ 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}
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.