
Show HN: Ghostwheel – easy spec, side effect detection and tracing for Clojure - gnl
https://github.com/gnl/ghostwheel
======
gnl
Fellow Clojurians, I present to you, Ghostwheel.

It makes the writing, reading, refactoring, testing, instrumentation and
stubbing of function specs easy; introduces a concise syntax for inline fspec
definitions; helps keep track of side effects; and makes general debugging
almost fun, with full evaluation tracing of function I/O, local bindings and
all threading macros.

It's Alpha software and the Clojure port, while essentially functional, still
needs some love to achieve full feature parity with ClojureScript – most
prominently missing at the moment is the tracing functionality.

To steal a quote from Nathan Marz' Specter in a blatant attempt at a so far
likely undeserved comparison to its indispensability, I like to think of
Ghostwheel as clojure.spec's missing piece. It has become quite essential to
me and I hope that you will find it useful too.

Feedback, PRs, and issue reports are welcome and much appreciated.

Do your thing, HN.

~~~
divs1210
This looks great! Is there a way to make it work with existing specced code? I
already have a large codebase with lots of fdefs. Can Ghostweel work with them
without modification?

Thanks!

~~~
gnl
At the moment you can set the gspec to nil, but that would simply disable
s/fdef generation and all of the spec-related magic. I'm planning to introduce
a configuration option with the next release to force Ghostwheel to trust that
there's an external s/fdef for that function and still do all the spec stuff.

There may be some limitations on this compared to using inline gspecs – I have
to play around with it a bit, but I think it should work fine. Until then, you
can still use Ghostwheel for tracing and side effect detection though.

------
cutler
Is it just me or is Clojure(script) becoming more and more syntax-heavy with
each passing year?

~~~
yen223
A subtle advantage of having a macro system is that you only pay the price of
having unconventional syntax if you opt into it. You can keep the core
language small and push weird syntax into macros, which can be imported like
libraries.

The core language of Clojure is pretty small and simple compared with most
other languages.

~~~
gnl
While that is true of the basic building blocks of the language, clojure.spec
for example does have an overly verbose syntax (I would define it that way,
even though it doesn't introduce new basic syntax elements) for function specs
and that was one of the main motivations for writing Ghostwheel.

I wouldn't see this as some sort of development in Clojure though and I don't
really know if that's what cutler meant anyway. Maybe he'll elaborate.

------
pka
This looks promising, can you expand on how this differs from clojure.spec and
core.typed?

~~~
gnl
This is basically generative testing using clojure.spec in a nice package with
a cherry on top and a few extras.

core.typed still seems to be quite experimental and not yet production-ready,
but it certainly looks very promising and I'm keeping an eye on it. It
currently also doesn't work on ClojureScript, which has been the primary
platform for Ghostwheel so far.

------
badsavage
Cool, will try it out!

