Slide 1

Slide 1 text

re-find Michiel Borkent
 @borkdude
 Dutch Clojure Days 2019-04-06 discover functions with spec

Slide 2

Slide 2 text

No content

Slide 3

Slide 3 text

No content

Slide 4

Slide 4 text

No content

Slide 5

Slide 5 text

?

Slide 6

Slide 6 text

No content

Slide 7

Slide 7 text

?

Slide 8

Slide 8 text

No content

Slide 9

Slide 9 text

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

Slide 10

Slide 10 text

https://re-find.it

Slide 11

Slide 11 text

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)

Slide 12

Slide 12 text

Why not just try everything without using spec?

Slide 13

Slide 13 text

Why use spec for this? Recommend only idiomatic functions
 


Slide 14

Slide 14 text

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

Slide 15

Slide 15 text

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

Slide 16

Slide 16 text

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

Slide 17

Slide 17 text

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

Slide 18

Slide 18 text

spec + exact match

Slide 19

Slide 19 text

spec + type match

Slide 20

Slide 20 text

permutation of args

Slide 21

Slide 21 text

Finitize

Slide 22

Slide 22 text

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

Slide 23

Slide 23 text

web + lib/CLI + JavaFX

Slide 24

Slide 24 text

Thank you! Questions or suggestions?
 @borkdude