Sorry, I read your original email on my phone and misread part of your code 
(thinking I’d seen an `instrument` call in there), so I thought it was the 
problem with instrumentation breaking (some) protocol-based functions.

 

Now I look at this on the big screen, I realize my mistake.

 

I agree that this does look very odd. I’ll be interested to hear an explanation 
for why (partial satisfies? Game) and #(satisfies? Game %) are not equivalent 
in this context.

 

Sean Corfield -- (970) FOR-SEAN -- (904) 302-SEAN
An Architect's View -- http://corfield.org/

"If you're not annoying somebody, you're not really alive."
-- Margaret Atwood

 

On 12/30/16, 4:16 PM, "John Schmidt" <clojure@googlegroups.com on behalf of 
john.schmid...@gmail.com> wrote:

 

Thanks for the reply Sean.

 

Could you explain a bit more why/how this is the same issue? The ticket seems 
to revolve around instrumentation and results in exceptions, not validation 
failures. And if the issue is with protocol functions, how come the ::game1 
spec works while the ::game2 spec doesn't?

On Friday, December 30, 2016 at 11:24:30 PM UTC+1, Sean Corfield wrote:

See http://dev.clojure.org/jira/browse/CLJ-1941 (in particular, the comments 
about protocols)

 

Sean Corfield -- (970) FOR-SEAN -- (904) 302-SEAN
An Architect's View -- http://corfield.org/

"If you're not annoying somebody, you're not really alive."
-- Margaret Atwood

 

On 12/30/16, 6:42 AM, "John Schmidt" <clo...@googlegroups.com on behalf of 
john.sc...@gmail.com> wrote:

 

Hello folks!

 

I have the following two clj files (I've tried to come up with a minimal 
example):

 

core.clj

--------------

(ns spec-test.core
  (:require [clojure.spec :as s]))
 
(defprotocol Game
  (move [game]))
 
(s/def ::game1 #(satisfies? Game %))
(s/def ::game2 (partial satisfies? Game))
foo.clj

--------------

(ns spec-test.foo
  (:require [spec-test.core :refer [Game]]))
 
(defrecord Foo [])
 
(extend-type Foo
  Game
  (move [game]))
 
 
 
Here's a REPL session that explains my problem:
 
➜  spec-test lein repl
WARNING: boolean? already refers to: #'clojure.core/boolean? in namespace: 
cider.inlined-deps.fipp.v0v6v4.fipp.visit, being replaced by: 
#'cider.inlined-deps.fipp.v0v6v4.fipp.visit/boolean?
nREPL server started on port 58606 on host 127.0.0.1 - nrepl://127.0.0.1:58606
REPL-y 0.3.7, nREPL 0.2.12
Clojure 1.9.0-alpha14
Java HotSpot(TM) 64-Bit Server VM 1.8.0_92-b14
    Docs: (doc function-name-here)
          (find-doc "part-of-name-here")
  Source: (source function-name-here)
 Javadoc: (javadoc java-object-or-class-here)
    Exit: Control+D or (exit) or (quit)
 Results: Stored in vars *1, *2, *3, an exception in *e
 
user=> (ns spec-test.core)
nil
spec-test.core=> (require 'spec-test.core :reload)
nil
spec-test.core=> (require 'spec-test.foo :reload)
nil
spec-test.core=> (satisfies? Game (spec-test.foo/->Foo))
true
spec-test.core=> ((partial satisfies? Game) (spec-test.foo/->Foo))
true
spec-test.core=> (s/explain ::game1 (spec-test.foo/->Foo))
Success!
nil
spec-test.core=> (s/explain ::game2 (spec-test.foo/->Foo))
val: #spec_test.foo.Foo{} fails spec: :spec-test.core/game2 predicate: (partial 
satisfies? Game) <---- WAAAAAT
nil
 
I have no idea what is going on here, but it seems the `extend-type` is 
important. If I inline the Game protocol implementation in the defrecord, it 
works.
 
Any ideas?
 
Thanks,
John
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clo...@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to