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

Thoughts about fdef utils? #72

Open
vincentjames501 opened this issue Aug 22, 2017 · 6 comments
Open

Thoughts about fdef utils? #72

vincentjames501 opened this issue Aug 22, 2017 · 6 comments

Comments

@vincentjames501
Copy link

Just wanted to stir up a conversation about this. I personally find specing functions to be tedious for most, simple functions.

Assume we had this spec:

(ds/spec ::user {::id   spec/uuid?
                 ::age  spec/pos-int?
                 ::name spec/string?})

Assume we want to spec this function:

(defn teenager?
  [user]
  (<= 13 (::age user) 19))

It would be neat if we could somehow spec this function easier

(ds/specf teenager? 
  [::user] ; args
  spec/boolean? ; ret
  nil ; fn
)

Or even with a Schema like macro:

(ds/defn teenager? :- spec/boolean?
  [user :- ::user]
  (<= 13 (::age user) 19))

I haven't actually fleshed out any of my thoughts, just wanted to see what you thought about some function specing utilities.

@ikitommi
Copy link
Member

Hi. There is a similar discussion in the Schema repo: plumatic/schema#366 I think the schema-syntax would be great for spec too.

@vincentjames501
Copy link
Author

I personally like the macro approach as it makes it easier to look at one place and see the semantics of the function. I'd rather just cover the simple/common cases and if the user needs something more advanced they should just use fdef or something more low-level directly.

@pablobcb
Copy link

+1 !!!!!!!!!

@ikitommi
Copy link
Member

Related: https://groups.google.com/forum/m/#!topic/clojure/0wqvG2sef8I

The goal is to add the macro to orchestra, as a tool to help encourage spec'ing all functions.

@metametadata
Copy link
Contributor

@ikitommi
Copy link
Member

ikitommi commented Jan 9, 2022

Related: plumatic/schema#366 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants