Fork me on GitHub

Anyone knows if the following plugin somehow works with emacs/cider?


That library alters the stacktrace printing functions. It doesn't integrate with your editor. It'll behave the same in a Cider REPL. The Cider Error display is already pretty good, though.


@john Right, I forgot that systems are components too!


Did anyone used What is the difference between region and polygon? How to compute if points is in polygon or not?


@troglotit when you talk about geographic features then you would use the notion of region. When you talk about the actual implementation, then its a polygon. You can use geo.poly/region-contains? for point in polygon computations.


how geofeatures differ from their implementation? hmm, but yeah, I found this But I’m not sure if what they meaning is common meaning.


Is there any performance trade off between the use of every? and subset? in clojure?


subset? is implemented using every?

(defn subset? 
  "Is set1 a subset of set2?"
  [set1 set2]
  (and (<= (count set1) (count set2))
       (every? #(contains? set2 %) set1)))


I'm looking for a good way to define some functionality contract - similar to a protocol, but not dependent on types. For example, I might have a contract by which my program interacts with a db with functions like query-data, transform-1, transform-2, store-data, etc. Normally I'd use a protocol for something like this, but mongo and sql connections are both maps (containing mongo and sql types as values), not distinct values Furthermore, I'd love to be able to have multiple mongo implementations (same type) and be able to def db-implementation to be one or the other. Is there a good way to approach this without having to define a bunch of my own "wrapper" types and construct one to bind to db-implementation so defprotocols can discern between them?


Would multimethods work @jmromrell?


I could use a multimethod for each function in the contract, but it loses the benefit of a protocol where it fully encapsulates the definition and implementation of each contract in one place

👍 4

When I see a protocol, it's obvious what the contract is. When I see a bunch of multimethods scattered around a large namespace, it's a lot harder to read and less clear how to extend the contract with a new complete implementation


can anyone help me use nippy to freeze a straight to an input stream?


what semantics do you expect saving a file?


e.g. are you serializing the file object which is basically just the path of the file without contents, or do you want to save the contents of the file?


the first is kind of crazy, but could be something you want for some reason, but I am going to proceed with assuming you want the second


the second


almost certainly it only makes sense to get some kind of value of the contents of the file out when decoding


(you don't want decoding to somehow write the contents to a tmp file and then return a file object pointing to that tmp file)


so I would suggest the first step in encoding to be a similar process, get some kind of value of the contents of the file


I’m trying to avoid reading the file into memory, so I was hoping I could use nippy/freeze-to-out in combination with maybe a to get an inputstream of the serialized file contents


I’m trying to extend slurp to an additional class (jGit ObjectLoader) but I’m struggling to make it work:

(extend ObjectLoader$SmallObject
  (assoc io/default-streams-impl
         :make-input-stream (fn [x opts] (println "Opening stream") (.openStream x))
         :make-reader #'io/inputstream->reader))
I would think that this should at least print “Opening stream” when calling slurp on a SmallObject instance but instead I get an exception from input-stream->reader that SmallObject can’t be coerced to InputStream


Also let me know if this is a bad idea 😄


(extend ObjectLoader$SmallObject
  (assoc io/default-streams-impl
         :make-input-stream (fn [x opts] (println "Opening stream") (.openStream x))
         :make-reader (fn [x opts] (io/reader (.openStream x)))))
this works


Alright, I somehow assumed make-input-stream is also used by `make-reader in some way but it seems like it’s not?


(extend ObjectLoader
  (assoc io/default-streams-impl
         :make-input-stream (fn [x opts] (.openStream x))
         :make-reader (fn [x opts] (io/reader (.openStream x)))))
Guess this does the job.


As far as I remember, you cannot extend Java classes with Java interfaces. Only with protocols. (I assume io/IOFactory is an interface; if it's a protocol, then something else is a problem).


@U086AG324 it’s a protocol and the snippet above did the trick… I was confused because I - for some reason - assumed make-reader would internally use make-input-stream