Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #33: Add >defmethod #34

Closed
wants to merge 1 commit into from
Closed

Fix #33: Add >defmethod #34

wants to merge 1 commit into from

Conversation

divs1210
Copy link

@divs1210 divs1210 commented Feb 2, 2020

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)))

@gnl
Copy link
Owner

gnl commented Feb 17, 2024

@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).

@gnl
Copy link
Owner

gnl commented Mar 14, 2024

Thanks!

@gnl gnl closed this Mar 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

>defmethod
2 participants