Fork me on GitHub
#clojure
<
2016-05-10
>
josh_tackett00:05:40

Does anyone know of a clojure wrapper for Jedis?

josh_tackett00:05:50

or if Carmine will do the key lookup like Jedis will?

malch00:05:59

can someone help me with compojure-api?

malch00:05:29

I’m trying to add custom format middleware for protobuf, but cannot make it work properly

malch00:05:08

Found this old issue: https://github.com/metosin/compojure-api/issues/61, but there are no hints

currentoor04:05:07

Anyone every compare images in clojure/java? Any suggestions?

beatngu1306:05:11

Hey guys! I’m writing a report about Clojure at my alma mater. Does anyone know where I can get Rich’s paper „The Clojure Programming Language“ (proceedings of the 2008 symposium on dynamic languages)?

mac09:05:48

Is there an elegant way of passing clauses as a vector to core.match/match?

chunsj12:05:34

@currentoor I’ve been used for web scraping. I’ve used it with firefox driver and chrome driver.

xcthulhu16:05:25

You could try OpenCV, although I've never used its Java bindings http://docs.opencv.org/java/2.4.11/

bassam.khouri18:05:47

Hi everyone.. I'm new to clojure and am in the learning stages. I encountered an error and am unsure how to solve it. In one project, I have a function where I'm invoking a command on a remote REPL. The command on the remote REPL returns a tagged object #object[com.example.namespace.DoubleEntity 0x5359c6c8 "{:mykey \"value\", :mykey2 \"value2\" }"].. But my function is returning the following error: RuntimeException No reader function for tag object clojure.lang.LispReader$CtorReader.readTagged (LispReader.java:1245). Any ideas how I can get my project's reader to properly read this object?

plexus18:05:14

@bassam.khouri: the easiest is probably to change how the remote represents that object, you can implement print-method for that type

plexus18:05:38

pseudo-code assuming your type takes positional arguments

plexus18:05:48

(defmethod print-method com.example.namespace.DoubleEntity [v ^java.io.Writer w]
  (.write w (str "(com.example.namespace.DoubleEntity. " 
                 (prn (:mykey v))
                 " "
                 (prn (:mykey2 v))
                 ")")))

radon18:05:49

I want an infinite sequence of integers starting at 1. Is there something more elegant than (map inc (range))?

plexus18:05:10

(iterate inc 1)

jr18:05:19

user=> (take 10 (iterate inc 1))
(1 2 3 4 5 6 7 8 9 10)

radon18:05:31

Beautiful! Thank you.

pbostrom18:05:50

(rest (range))

bassam.khouri18:05:05

@plexus: Thanks for the suggestion.

bassam.khouri20:05:37

@plexus: I looked into the print-method and it doesn't appear that it will do the job. first, it only prints to the screen and may return nil. Second, this will change the return for the entire remote function. The remote function resides in a library and it may cause more work than needed.

plexus20:05:22

@bassam.khouri: you don't actually have to call print-method, it's used internally by the REPL to represent an object as a string. Providing that defmethod should be enough.

bassam.khouri20:05:45

I did some tests on my local REPL

bassam.khouri20:05:33

`user=> (deftype FOO [] ) user.FOO user=> (prn (FOO.)) #object[user.FOO 0x4540e5da "[email protected]"] user=> (defmethod print-method FOO [v ^java.io.Writer w] #_=> (.write w "<<-FOO->>")) #object[clojure.lang.MultiFn 0x4b7b90ce "[email protected]"] user=> (prn (FOO.)) <<-FOO->> nil user=> (FOO.) <<-FOO->> user=> (FOO) RuntimeException Expecting var, but FOO is mapped to class user.FOO clojure.lang.Util.runtimeException (Util.java:221) `

plexus20:05:36

If you can't add that defmethod on the remote side then you'll have to do your own parsing. As far as I can tell the representation you get now is not valid EDN

bassam.khouri20:05:10

the representation I'm getting is from the repl or something

bassam.khouri20:05:32

`
user=> (deftype FOO [] )
user.FOO
user=> (prn (FOO.))
#object[user.FOO 0x4540e5da "[email protected]"]

bassam.khouri20:05:49

that's without the print-method

bassam.khouri20:05:08

my local repl is using Clojure 1.7.0

plexus20:05:43

Yeah exactly, the Clojure reader won't be able to read that. Not everything can simply round trip like that

bassam.khouri20:05:19

what's odd is the the remote server doesn't encounter that problem.

bassam.khouri20:05:33

and the same tagged litteral is being used..

bassam.khouri20:05:47

The "object" is defined in a clojure library

plexus20:05:56

Is it parsing that output?

bassam.khouri20:05:08

it does.. otherwise it would have been fixed simple_smile

bassam.khouri20:05:21

Is there a way to update the readers in my project?

plexus20:05:18

You can add tagged literals, but that output is not a valid tagged literal

bassam.khouri20:05:24

Can I add custom litterals?

plexus20:05:25

A tagged literal looks like #namespace/tagname valid-clojure-literal

plexus20:05:49

Yes, you can, but it won't solve your problem

bassam.khouri20:05:02

I have the project as a dependency.

bassam.khouri20:05:28

how can I make my reader parse a deftype defined in a library?

plexus20:05:36

Somebody correct me if I'm wrong, but I think that if you can't change that output you'll have to roll your own parser.

plexus20:05:21

On the other hand if you can add that (defmethod print-method on the server side then the problem is solved. That's exactly why print-method is a multimethod, so you can extend it to new types. That is assuming you have access to the server.