Re: Mixing [org.clojure/clojure "1.9.0-alpha14"] and [org.clojure/tools.analyzer.jvm "0.7.0"] breaks protocol resolution?
Nevermind, i was misusing protocols and have clashing interfaces in concrete object. On Thursday, March 9, 2017 at 11:57:17 PM UTC-3, Paulo César Cuneo wrote: > > Hi When im using [org.clojure/clojure "1.9.0-alpha14"] together with > [org.clojure/tools.analyzer.jvm "0.7.0"] . > It breaks reduce, may be i m misusing protocols, am i ? > > What seems to be happening is imap-cons is receiving seq as o, so it cant > match a proper case. > Guess it happens because java.util.List wins over java.util.Map$Entry in > protocol resolution. > > Odd things is, removing analyzer deps changes behavior. > > (defn- imap-cons > [^IPersistentMap this o] > > #_(defproject cast-exception "0.1.0-SNAPSHOT" > :description "FIXME: write description" > :url "http://example.com/FIXME; > :license {:name "Eclipse Public License" > :url "http://www.eclipse.org/legal/epl-v10.html"} > :dependencies [[org.clojure/clojure "1.9.0-alpha14"] > [org.clojure/tools.analyzer.jvm "0.7.0"] > #_[org.clojure/algo.monads "0.1.6"]] > :main ^:skip-aot cast-exception.core > :target-path "target/%s" > :profiles {:uberjar {:aot :all}}) > > (ns cast-exception.core > (:gen-class)) > > (defrecord Some [a b]) > (defprotocol IMap > (-map [ _ ])) > > (extend-type nil > IMap > (-map [ a ] a)) > > (extend-type Object > IMap > (-map [ a ] a)) > > (extend-type java.util.List > IMap > (-map [ a ] > (map -map a))) > > (extend-type java.util.Map$Entry > IMap > (-map [ a ] > [(-map (first a)) > (-map (second a))])) > > (extend-type java.util.Map > IMap > (-map [ a ] > (if (record? a) > (into a (map #(-map %) (seq a))) > (into (empty a) (map #(-map %) (seq a)) > > (let [a (->Some (quote b) 2)] > (-map a)) > > Cheers. > > -- 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.
Mixing [org.clojure/clojure "1.9.0-alpha14"] and [org.clojure/tools.analyzer.jvm "0.7.0"] breaks protocol resolution?
Hi When im using [org.clojure/clojure "1.9.0-alpha14"] together with [org.clojure/tools.analyzer.jvm "0.7.0"] . It breaks reduce, may be i m misusing protocols, am i ? What seems to be happening is imap-cons is receiving seq as o, so it cant match a proper case. Guess it happens because java.util.List wins over java.util.Map$Entry in protocol resolution. Odd things is, removing analyzer deps changes behavior. (defn- imap-cons [^IPersistentMap this o] #_(defproject cast-exception "0.1.0-SNAPSHOT" :description "FIXME: write description" :url "http://example.com/FIXME; :license {:name "Eclipse Public License" :url "http://www.eclipse.org/legal/epl-v10.html"} :dependencies [[org.clojure/clojure "1.9.0-alpha14"] [org.clojure/tools.analyzer.jvm "0.7.0"] #_[org.clojure/algo.monads "0.1.6"]] :main ^:skip-aot cast-exception.core :target-path "target/%s" :profiles {:uberjar {:aot :all}}) (ns cast-exception.core (:gen-class)) (defrecord Some [a b]) (defprotocol IMap (-map [ _ ])) (extend-type nil IMap (-map [ a ] a)) (extend-type Object IMap (-map [ a ] a)) (extend-type java.util.List IMap (-map [ a ] (map -map a))) (extend-type java.util.Map$Entry IMap (-map [ a ] [(-map (first a)) (-map (second a))])) (extend-type java.util.Map IMap (-map [ a ] (if (record? a) (into a (map #(-map %) (seq a))) (into (empty a) (map #(-map %) (seq a)) (let [a (->Some (quote b) 2)] (-map a)) Cheers. -- 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.
Re: [core.logic] - why doesnt ITake/take* implementation always return a seqable?
Just answering myself found i should bind with choice as it is done in reifyg (defn export [out vs gs] (fn [a] (let [a' (bind a gs) as (take* (bind a' (fn [s] *(choice (walk* s vs)* * empty-f)*)))] (bind a (== out as) On Tuesday, January 3, 2017 at 4:14:20 PM UTC-3, Paulo César Cuneo wrote: > > I was hacking around with core.logic, trying to implement a "bind var in > sub process". > > So that this this succeeds: > (run [q] >(fresh[a] > (runsub [q] ;; will "export 'q" or "bind 'q in > caller context" > [(== a 1) (== q 1)]) ;; 'a will be bound only inside this > context > (lvaro a))) ;; 'a is not bind in caller context > (1) > > I didn't want to do term replacement, so i figure i could run goals an > return the original substitution. > (fn[a] > (let[ a' (take* (reduce bind a goals))] > (magic-happens q a' a) ;; generate an mplus binding lvar q with a' > values inside a. > ) > > Anyway :D haha. > > I found that, take* throws an exception because > > > (let [x (lvar) > as (tramp (-> empty-s > ((conde [(== x 1)] > [(== x 2)] > ls (take* as)] > ls) > (#object[clojure.core.logic.Substitutions 0x7c509c4b "{ > 1}"]*AbstractMethodError > clojure.lang.RT.seqFrom (RT.java:533)* > > > > It happens because : > (deftype Substitutions > > ITake > (take* [ this ] this) ;; why not seqable? > > Seems easy to fix, but i bet there be code depending on return not being a > seqable. > (take* [ this ] [this]) > > Bye. > -- 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.
[core.logic] - why doesnt ITake/take* implementation always return a seqable?
I was hacking around with core.logic, trying to implement a "bind var in sub process". So that this this succeeds: (run [q] (fresh[a] (runsub [q] ;; will "export 'q" or "bind 'q in caller context" [(== a 1) (== q 1)]) ;; 'a will be bound only inside this context (lvaro a))) ;; 'a is not bind in caller context (1) I didn't want to do term replacement, so i figure i could run goals an return the original substitution. (fn[a] (let[ a' (take* (reduce bind a goals))] (magic-happens q a' a) ;; generate an mplus binding lvar q with a' values inside a. ) Anyway :D haha. I found that, take* throws an exception because > (let [x (lvar) as (tramp (-> empty-s ((conde [(== x 1)] [(== x 2)] ls (take* as)] ls) (#object[clojure.core.logic.Substitutions 0x7c509c4b "{ 1}"]*AbstractMethodError clojure.lang.RT.seqFrom (RT.java:533)* > It happens because : (deftype Substitutions ITake (take* [ this ] this) ;; why not seqable? Seems easy to fix, but i bet there be code depending on return not being a seqable. (take* [ this ] [this]) Bye. -- 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.
Common runtime errors in clojure
Hi group, I was googling for enumeration of commons runtime errors in clojure, but i couldnt find anything much. Stuart Sierra has a couple of blog post on do/donts in clojure, but is not an exhaustive listing. I understand that using interop will inherit most of the runtime errors you can create in java, but even when staying inside the clojure realm there are some common cases of errors. For example, 1 - applying type specific ops on wrong type : ;; math ops. (+ 1 nil) ; => NullPointerException. (+ 1 "") ; => ClassCastException. 2 - call on non-callable: (map nil [1 2 3]) ; => NullPointerException. ("asdf" 2) ; => ClassCastException. 3 - cant destruct (let [[f s] 1] f) ; => UnsupportedOperationException nth I guess most of errors are due to bad plumbing. Do you have any insights on these or more examples? Bye and Thanks. -- 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.