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

Use clojure.spec instead of atom and function overwriting #108

Open
8 tasks done
elenam opened this issue Jun 22, 2016 · 6 comments
Open
8 tasks done

Use clojure.spec instead of atom and function overwriting #108

elenam opened this issue Jun 22, 2016 · 6 comments

Comments

@elenam
Copy link

elenam commented Jun 22, 2016

  • Make it work with multiple arguments (track arg numbers)
  • Make it work with varargs
  • Make it work with multiple arities
  • Process the spec hashmap (instead of an atom) in exception handling
  • Exception data handling
  • Pretty-printing failing args
  • Make it work with nilable
  • Add tests, especially for multi-predicate and nilable
@real-mj-song
Copy link

screenshot from 2016-06-23 16-12-06

@real-mj-song
Copy link

real-mj-song commented Jun 23, 2016

clojure.lang.ExceptionInfo: Call to #'spec-ex.spec-inte/+ did not conform to spec: :: {:clojure.spec/problems {[:args] {:pred number?, :val "", :via [], :in [4]}}, :clojure.spec/args (3 4 6 7 "")}
In: [4] val: "" fails at: [:args] predicate: number?
:clojure.spec/args (3 4 6 7 "")

Note: the message is "Call to #'spec-ex.spec-inte/+ did not conform to spec:", the rest is data.

@elenam
Copy link
Author

elenam commented Jun 28, 2016

Specs for core functions need to be defined before the function is redefined or in a different file.

@real-mj-song
Copy link

  • For every function with inlining, we can't use spec without overwriting it.
  • Put spec before a function
    -> specify conditions for the core function
  • Put spec after a function
    -> specify conditions for the overwritten function

@elenam
Copy link
Author

elenam commented Jul 5, 2016

For nilable predicates the data is:

{:clojure.spec/problems {[:args :check-map :clojure.spec/nil] {:pred nil?, :val :s, :via [], :in [0]}, 
[:args :check-map :clojure.spec/pred] {:pred map?, :val :s, :via [], :in [0]}}, :clojure.spec/args (:s)}

@real-mj-song
Copy link

For some functions, we need to put specs after overwriting them (and we can't get the function name in this case). I think this happens in two cases.

  1. When the function has different numbers of :inline-arities like #{2 3}
  2. When the function has only :inline without :inline-arities

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

2 participants