[ANN] Pinpointer: yet another spec error reporter

122 views
Skip to first unread message

OHTA Shogo

unread,
Dec 11, 2017, 9:23:38 AM12/11/17
to Clojure
Hi, all

I’m happy to announce the first release of Pinpointer, yet another implementation of spec error reporter based on a precise error analysis.


Pinpointer provides functionalities very similar to the existing spec error reporters (eg. Expound[1], Inspectable[2] etc.), that is, reporting spec errors in a more human-readable way.


Unlike those libraries, which analyze spec errors using several heuristics, Pinpointer performs a systematic error analysis traversing a pair of the spec and the input. This makes it possible to report the error even in complicated cases where s/conformer would transform the input value, like the following:

=> (require '[pinpointer.core :as p] '[clojure.spec.alpha :as s])
=> (p/pinpointer (s/and string? (s/conformer seq) (s/* #{\a})) "aabaa")
Detected 1 spec error:
----------------------------------------------------------------------
(1/1)


    Cause: (\a \a \b \a \a)
                  ^^      
 Expected: #{\a}


   --- This comes originally from ---


 Original: "aabaa"
           ^^^^^^^
     Spec
  Applied: (s/and string? (s/conformer seq) (s/* #{\a}))


----------------------------------------------------------------------
nil
user=>


(BTW the above example is just a demo for Pinpointer's capability, and it doesn't mean to encourage you to write specs like that.)

On the other hand, one of the downsides of the library is that Pinpointer has to know in advance the behaviors of the spec macros involved in a spec form for its error analysis. Note also that, Pinpointer occasionally uses  eval under the hood (at least for now), so it’s basically intended to be used for development purpose only.

I hope you’ll like it :)

Thanks,
Shogo

Ben Brinckerhoff

unread,
Dec 11, 2017, 7:20:21 PM12/11/17
to Clojure

Very cool! Excellent work.
Reply all
Reply to author
Forward
0 new messages