ghostwheel
ghostwheel copied to clipboard
Fix #33: Add >defmethod
This PR fixes #33
Example:
(defmulti demo pos?)
(>defmethod demo
true
[x]
[pos? => nil?]
(println "It's positive"))
(>defmethod demo
false
[x]
[(s/or :zero zero? :neg neg?) => nil?]
(println "It's zero or negative!"))
(demo 1)
;; => "It's positive"
(demo -3)
;; => "It's zero or negative!"
It achieves this by delegating to >defn:
(do
(>defn demo_G__20347
[x]
[pos? => nil?]
(println "It's positive"))
(defmethod demo
true
[x]
(demo_G__20347 x)))
(do
(>defn demo_G__20352
[x]
[(s/or :zero zero? :neg neg?) => nil?]
(println "It's zero or negative!"))
(defmethod demo
false
[x]
(demo_G__20352 x)))
@divs1210 – I'm necromancing this PR to say thanks and ask if you'd like to resubmit it to the fulcrologic/guardrails repo where all future development of this part of Ghostwheel's functionality will be happening (see the updated README for details).
Thanks!