gnl/ghostwheel

Call to ghostwheel.core/>defn did not conform to spec.

Closed this issue · 3 comments

This example:

(ns app
  (:require
   [spec-tools.data-spec :as ds]
   [ghostwheel.core :as g :refer [>defn >defn- >fdef => | <- ?]]))

(def significant-correlations
  (ds/spec
   {:input keyword?
    :score int?
    :average float?
    :correlations {:biomarker keyword?
                   :slope float?
                   :rsq float?
                   :datapoints int?}}))

(>defn make-html
       [data]
       [significant-correlations :ret string?]
       "")

Gives me this error when I try to compile:

Syntax error macroexpanding ghostwheel.core/>defn.
Call to ghostwheel.core/>defn did not conform to spec.
-- Spec failed --------------------

  (... ... ... [significant-correlations ... ...] ...)
                ^^^^^^^^^^^^^^^^^^^^^^^^

should be one of: (quote =>), :ret

or value

  (... ... ... [significant-correlations :ret string?] ...)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

should satisfy

  nil?

I'm having a really hard time trying to figure out how to fix this, any ideas?

The library I'm using to define my more concise significant-correlations spec is https://github.com/metosin/spec-tools/blob/master/docs/02_data_specs.md

gnl commented

Doesn't look like Ghostwheel is compatible with spec-tools at the moment, but it seems it might just be a matter of easing the >defn spec itself, so it doesn't get in the way unnecessarily. If true, that should be an easy fix. I'll look into this for the next release, which has been way overdue and I'm not making any promises, but I'm hoping it won't be much longer. :)

I actually think i was holding spec-tools.data-spec wrong; this thread let to the right syntax for my case: https://www.reddit.com/r/Clojure/comments/sb3e8n/comment/htzgzbq/?utm_source=share&utm_medium=web2x&context=3.

Everything seems to be working now! I anticipate I might have other questions about how to use ghostwheel effectively - should I ask them as separate issues here or on another forum?