Hi everyone,
A couple of coworkers and I were chatting about what some of our biggest
problems with (our) Clojure code was, and came up with this:
https://github.com/diogo149/outfn ! We just finished making it, so we
haven't really battle-tested it, but we would love to hear feedback and
general thoughts about the approach, and possibly have it evolve with the
community.
The readme has a bunch examples, so I won't copy-paste it all here, but
here is a list of things that we are hoping to acheive:
- bad/inconsistent variable naming
- function call clarity
- function dispatch based on inputs instead of arity and allowing the usage
of a threading macro no matter the order of arguments with 0 overhead
- static DRY verification
- decomposing big let blocks easily
- dependency passing without coupling (and anything that makes us want to
use a :dynamic var)
- automatic creation of glue code
Some of our favorite examples:
- keyword arguments for function call clarity
(do-something :user-map x :password-list y)
- decomplecting order from function arguments:
(defoutfn map-v2.0
"Like map, but better"
[f coll]
(map f coll))
;; threading in a collection
(->> 5
range
(map-v2.0 :f inc :coll)) ;; (1 2 3 4 5)
;; threading in a function
(->> 5
(partial +)
(map-v2.0 :coll (range 5) :f)) ;; (5 6 7 8 9)
- macroexpand-time validation
(defoutfn outfn
"what's up doc"
[foo]
:foo)
(when nil
;; this doesn't get run
(outfn :fo 2))
;; Error! Invalid set of keys #{:fo} for #'outfn.core/outfn
- declarative function calls without glue code
(defoutfn foo-fn {:output :foo}
"Docstring"
([a] 3)
([b] 4)
([c d] 5))
(defoutfn bar-fn {:implicits #{#'foo-fn}}
"what's up doc"
[foo] foo)
;; Look ma, no glue code
(bar-fn :foo 2) ;; 2
(bar-fn :a nil) ;; 3
(bar-fn :b 42) ;; 4
(bar-fn :c 11 :d 22) ;; 5
;; I don't need to know what bar-fn needs - decoupling
(bar-fn :foo 2 :a 3 :b 4 :c 5 :d 6 :q 72) ;; 2
;; Laziness is a virtue
(bar-fn :foo 42 :a (throw Exception.)) ;; 42
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.