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

traverse example fails #184

Closed
sinistral opened this issue Nov 30, 2016 · 1 comment
Closed

traverse example fails #184

sinistral opened this issue Nov 30, 2016 · 1 comment

Comments

@sinistral
Copy link

The examples for cats.core/traverse throw "missing protocol method" exceptions in both Clojure (1.8.0) and ClojureScript (1.9.293). Using the example from the API documentation:

boot.user> (require '[cats.context :as ctx]
                    '[cats.core :as m]                    
                    '[cats.monad.maybe :as maybe])
;; => nil
boot.user> (defn inc-if-even
             [n]
             (if (even? n)
               (maybe/just (inc n))
               (maybe/nothing)))
;; => #'boot.user/inc-if-even
boot.user> (ctx/with-context maybe/context
             (m/traverse inc-if-even [2 4]))
java.lang.IllegalArgumentException: No implementation of method: :-get-context of protocol: #'cats.protocols/Contextual found for class: clojure.lang.PersistentVector
@sinistral
Copy link
Author

I have just discovered that I was missing the necessary (require '[cats.builtin]). I am terribly sorry for the noise.

cljs.user> (require '[cats.builtin])
;; => true
cljs.user> (require '[cats.context :as ctx]
                    '[cats.core :as m]                    
                    '[cats.monad.maybe :as maybe])
;; => nil
cljs.user> (defn inc-if-even
             [n]
             (if (even? n)
               (maybe/just (inc n))
               (maybe/nothing)))
;; => #'cljs.user/inc-if-even
cljs.user> (ctx/with-context maybe/context
             (m/traverse inc-if-even '(2 4)))
;; => #<Just (3 5)>
cljs.user> (ctx/with-context maybe/context
             (m/traverse inc-if-even '(2 4 5)))
;; => #<Nothing>
cljs.user> 

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

No branches or pull requests

1 participant