Michiel Borkent
April 06, 2019
150

# 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:

https://clojuredays.org/#Re-find:%20discover%20functions%20with%20spec

April 06, 2019

## Transcript

1. re-ﬁnd
Michiel Borkent
@borkdude
Dutch Clojure Days

2019-04-06

discover functions with spec

2. ?

3. ?

4. rationale for re-ﬁnd
• 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

5. https://re-ﬁnd.it

6. How does it work?
• re-ﬁnd searches within spec’ed functions

• so it needs a collection of specs (speculative, but could
be other specs for core or self-deﬁned functions)

7. Why not just try everything
without using spec?

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

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

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

11. Spec validation
(s/fdef clojure.core/inc
:args (s/cat :x number?)
:ret number?)
But (inc 1) is not equal to 1...

12. Spec validation
(s/fdef clojure.core//
:args (s/cat :numerator number?
:denominators (s/* number?))
:ret number?)
(= 1 (/ 1 1)) ;; true

13. spec + exact
match

14. spec + type
match

15. permutation of
args

16. Finitize

17. 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-ﬁnd lib works in Clojure and (self-hosted) CLJS

18. web + lib/CLI + JavaFX

19. Thank you!
Questions or suggestions?
@borkdude