Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Re-find: discover functions with spec

Re-find: discover functions with spec

Re-find is an app and a library that lets you interactively discover Clojure functions based on example in- and output values or predicates. In this talk we will see how it works and how it is implemented, using clojure.spec as the driving force.

About the speaker: Michiel Borkent is a software developer and Clojurian. He can be found as @borkdude in various places on the web.

This presentation was given at Dutch Clojure Days 2019:


Michiel Borkent

April 06, 2019

More Decks by Michiel Borkent

Other Decks in Programming


  1. re-find Michiel Borkent
 Dutch Clojure Days 2019-04-06 discover functions

    with spec
  2. None
  3. None
  4. None
  5. ?

  6. None
  7. ?

  8. None
  9. rationale for re-find • You are learning Clojure and don't

    know the names or even the existence of functions • You know a function exists, but forgot the order of arguments it takes
  10. https://re-find.it

  11. How does it work? • re-find searches within spec’ed functions

    • so it needs a collection of specs (speculative, but could be other specs for core or self-defined functions)
  12. Why not just try everything without using spec?

  13. Why use spec for this? Recommend only idiomatic functions

  14. Spec validation (s/fdef clojure.core/inc :args (s/cat :x number?) :ret number?)

    {:args [1]
 :ret 1}
  15. Spec validation (s/fdef clojure.core/inc :args (s/cat :x number?) :ret number?)

  16. Spec validation (s/fdef clojure.core/inc :args (s/cat :x number?) :ret number?)

    But (inc 1) is not equal to 1...
  17. Spec validation (s/fdef clojure.core// :args (s/cat :numerator number? :denominators (s/*

    number?)) :ret number?) (= 1 (/ 1 1)) ;; true
  18. spec + exact match

  19. spec + type match

  20. permutation of args

  21. Finitize

  22. Stack • Self-hosted CLJS • Low operational cost (just static

    HTML + JS) • No security risks (evaluation on server) • CodeMirror + parinfer layer • automatic paren matching, closing, highlighting • CLJC: re-find lib works in Clojure and (self-hosted) CLJS
  23. web + lib/CLI + JavaFX

  24. Thank you! Questions or suggestions?