Fork me on GitHub
#clojure
<
2017-09-28
>
shafeeq07:09:34

@seancorfield From https://dev.clojure.org/jira/browse/JDBC-37, > Clojure/core specifically wanted java.jdbc to move away from dynamically bound variables Is there somewhere the reasons for this are described?

shafeeq07:09:57

Is that reasoning mostly from a library API’s perspective? Or are there reasons to not use a dynamic var to do transactions even within application code, where we’re fairly certain that the statements are actually on the same thread?

genec10:09:07

I've been trying to use core.match to match on the type of a Record but haven't been able to figure out the syntax. Does anyone know how to reproduce the following condp but with core.match? (defrecord A [a]) (defrecord B [b]) (defrecord C [c]) (let [x (B. 2)] (condp = (type x) A "A" B "B" C "C" nil))

roklenarcic12:09:37

try saying `A instead of just A

roklenarcic12:09:31

here the result of type x is a class

roklenarcic12:09:02

why not just specify condition as (type A) instead of A

roklenarcic12:09:34

nvm you're looking for core match solution

roklenarcic12:09:49

btw does anyone have a good library for continuations in clojure?

qqq12:09:26

(ns server.snip.boof
  (:import [boofcv.struct.image GrayU8]))
results in:
1. Unhandled java.lang.ClassNotFoundException
   boofcv.struct.image.GrayU8

       URLClassLoader.java:  381  java.net.URLClassLoader/findClass
   DynamicClassLoader.java:   69  clojure.lang.DynamicClassLoader/findClass
          ClassLoader.java:  424  java.lang.ClassLoader/loadClass
now, I know that I have the boofcv loaded (via boot). Is there some way, via the repl, to dynamically get a list of all the classes / packages loaded?

roklenarcic13:09:23

classes are loaded on demand

roklenarcic13:09:11

jvm doesn't load classes which aren't used

qqq13:09:39

how do I debug something like this? docs says:

[org.boofcv/all "0.26"]
pulls in all the jars/classes and I'm trying to use http://boofcv.org/javadoc/boofcv/struct/image/GrayU8.html

roklenarcic13:09:45

well my IDE tells me all the jars I have in my build

roklenarcic13:09:54

and I can locate any class in those

roklenarcic13:09:13

your class is in ip artifact

roklenarcic13:09:48

and that dep pulls it

roklenarcic13:09:59

did you restart repl?

roklenarcic13:09:17

when you add dependencies you need to refresh your environment

beoliver14:09:23

does anyone know of a good way of instrumenting middleware so that I can step-debug through a particular wrap-something function. When I try C-u C-c-c (cider instrument?) it sometimes seems to work, but often not. My guess is that when the system is started - changes to the function no longer work. I thought that I could perhaps call out to another function that works like identity that I could then instrument?

ghadi14:09:49

check in #cider

ghadi14:09:54

not sure myself

noisesmith17:09:36

I don’t know how helpful #cider was, but the root issue here is that if you call (wrap-foo x) to make a handler, redefining wrap-foo doesn’t change that return value until you repeat that call - which likely means reloading the namespace in which the handler was wrapped after instrumenting the middleware

noisesmith17:09:00

and, depending on how you start up your server, you might also have to restart it

djebbz15:09:42

Hello, I have several functions speced with spec/fdef and I can easily generate tests in the REPL with spec.test/check fn-sym. How to integrate this functionality with clojure.test or clojure.test.check nicely without having to generate manually the inputs with prop/for-all ?

djebbz15:09:53

The guides at https://clojure.org/guides/spec#_testing and https://github.com/clojure/test.check don't show how to integrate functions spec'ed with fdef and clojure.test(.check)

djebbz15:09:25

Seems like spec.test is not really integrated with test.check and clojure.test, I would have to manually parse the result of fdef and pass it to clojure.test/report

briprowe15:09:45

is this expected behavior?

briprowe15:09:47

:64-bit-architecture ;; => :64-bit-architecture
  :energy-star/64-bit-architecture ;; => RuntimeError

briprowe15:09:38

it seems that if the name portion of a keyword would make a valid keyword then it should remain valid after adding a valid namespace portion

iarebatman17:09:28

Hey guys. Hopefully quick question...

iarebatman17:09:00

I'm trying to use java.jdbc with hugsql. Should work without a problem as far as I've read.

iarebatman17:09:34

I've got my dbspec in place and if I pass this directly to one of my hugsql-generated functions, it works great

iarebatman17:09:21

But if I attempt to (jdbc/get-connection dbspec) , I keep receiving an IllegalArgumentException saying that my PgConnection object is missing a required parameter

ghadi17:09:19

can you paste your redacted db spec?

iarebatman17:09:49

Yes, one moment

ghadi17:09:04

and what required parameter is it missing?

iarebatman17:09:41

(def dbspec { :dbtype "postgresql" :dbname (env :database-db) :host (env :database-server) :port (env :database-port) :user (env :database-user) :password (env :database-pass) })

iarebatman17:09:00

I honestly wish I knew - it doesn't tell me or give me any clue

iarebatman17:09:22

IllegalArgumentException db-spec org.postgresql.jdbc.PgConnection@187eff88 is missing a required parameter clojure.java.jdbc/get-connection (jdbc.clj:374)

dpsutton17:09:14

have you evaluated each of the (env :...) forms to ensure they are returning the value you are expecting?

iarebatman17:09:21

@U11BV7MTK yes, they all appear to be exactly what I expect. The only questionable one was the port, because it probably needs to be an int. I've manually replaced that line with 5432, however, and that doesn't matter.... And as I said - if I pass this same dbspec thru a hugsql-generated function, it works as expected

iarebatman17:09:04

I've looked at the docs and source for jdbc/get-connection, and I'm supplying all of the ones that are marked required - and since the same dbspec works thru hugsql, I honestly don't know what to do

iarebatman17:09:25

Anyone else run into anything like that?

chalcidfly17:09:49

Let’s say I take a function, like (defn whatever [x] (+ x x)), and a specific usage of this function, say (whatever 10), is there a way I can return the original function definition but with the args replaced? So in this case, (defn whatever [5] (+ 5 5))?

chalcidfly17:09:04

Not sure what to call. Argument-replacement, some kind of static analysis or something

reefersleep18:09:04

So like (replace-args [5] (partial whatever 10))?

chalcidfly18:09:40

Oh crap I meant (defn whatever [10] (+ 10 10))

noisesmith18:09:01

@chalcidfly you can get close if you replace defn with defmacro and use macroexpand

reefersleep18:09:04

what even do you mean 😄

noisesmith18:09:07

but there’s definitely nothing baked in

reefersleep18:09:47

(defn whatever [10] (+ 10 10)) wat

chalcidfly18:09:55

@reefersleep maybe more like (replace-args whatever 10), and that would output (defn whatever [10] (+ 10 10))

chalcidfly18:09:25

@noisesmith interesting, I hadn’t thought of macroexpand

reefersleep18:09:35

still doesn’t quite make sense to me

noisesmith18:09:36

user=> (defmacro whatever [x] `(+ ~x ~x))
#‘user/whatever
user=> (macroexpand-1 ‘(whatever 10))
(clojure.core/+ 10 10)

reefersleep18:09:42

can you have 10 as an arg?

reefersleep18:09:00

or not as an arg, but as a parameter denomination

chalcidfly18:09:28

Yeah @noisesmith that’s exactly what I’m thinking, but with regular functions instead

chalcidfly18:09:47

@reefersleep what do you mean by parameter denomination?

reefersleep18:09:04

as the name of an arg in an argument vector in a function definition

noisesmith18:09:09

there might be some trick based on clojure.tools.analyzer but it’s likely going to be a lot of work done by hand to create something that behaves that way

chalcidfly18:09:55

@reefersleep Yeah, any way of invoking it is fine. I’m trying to picture a new kind of tool for code debugging

chalcidfly18:09:07

@noisesmith that’s a solid lead, I’ll check that out

noisesmith18:09:52

some of the folks that work on tools.analyzer hang out here, if you can’t find a dedicated channel they are active in the clojure-dev channel

noisesmith18:09:14

tools.analyzer isn’t used by clojure itself, but it’s used by a lot of people who also work on clojure itself

reefersleep18:09:48

@chalcidfly what I mean is this:

(defn do-stuff [10] (+ 10 10))
CompilerException java.lang.Exception: Unsupported binding form: 10, compiling:(*cider-repl query*:145:6) 

noisesmith18:09:04

that’s not what he’s trying to do at all though

noisesmith18:09:26

this is about showing inline substitution to help you debug your code - eg. what edebug does in emacs with elisp code

reefersleep18:09:01

then I get the reference to analysis

noisesmith18:09:10

or what you would do by hand if you were trying to step through code by hand on a whiteboard

reefersleep18:09:34

so something like, what’s the editor by Chris Granger

chalcidfly18:09:54

Yeah, something like that

reefersleep18:09:01

well there you have it

reefersleep18:09:09

can’t you look in the Light Table source?

reefersleep18:09:20

or is their approach unacceptable?

chalcidfly18:09:22

Does light table actually do a full on replacement? I haven’t seen that

chalcidfly18:09:39

I just thought they did an instarepl kind of thing that turned out to be disappointing

chalcidfly18:09:45

But maybe I should give it another look

reefersleep18:09:28

The way that I think I’ve seen it is that for a function invocation, you can see the current values for symbols in like, little balloons or something like that

reefersleep18:09:44

I may be wrong

chalcidfly18:09:19

@reefersleep yeah, that’s pretty much what I’m envisioning, but like, a general library for that sort of thing

chalcidfly18:09:28

not necessarily tied to Light Table but usable in different tools

reefersleep18:09:25

Tear it out of Light Table, then! 😄 If they can do it in this specific way, I’m guessing you can generalize it.

chalcidfly18:09:49

It appears that the light table source code has exactly zero comments anywhere

reefersleep18:09:18

maybe I dreamt the balloon bit? or maybe that video is out of date

genec18:09:35

we need to port lighttable to vs code

genec18:09:01

@reefersleep I'm thinking about it, but it's complex. I've used the F# extension Ionide for vs code and something like that for Clojure would be insanely great

reefersleep18:09:45

I bet it is, @genec 🙂 Is there a video example of the greatness of Ionide? I’d like to see.

genec18:09:53

if i can figure out how to write vs code extensions in clojurescript, I would consider it

reefersleep18:09:04

I haven’t ever seen VS code in action, I’m an emacs man these days, but certainly not religiously so

genec18:09:06

here's a link to ionide and the author of it's a really good guy (very active in the F# community) https://www.youtube.com/watch?v=JWe1pOeh84U&amp;feature=youtu.be&amp;t=18m

genec18:09:59

It's written using Fable which is an F# to JS transpiler

genec18:09:09

So it should be doable with clojurescript

genec18:09:20

As I don't want to write JS or TypeScript

noisesmith18:09:52

I don’t know precisely what ionide does, but F# is strongly and statically typed, which are two features clojure lacks, and both features tend to make it easier to make helpful tooling

noisesmith18:09:22

you can’t make the same kind of far reaching assumptions in clojure code that you can in f#

genec18:09:37

yeah, but i think getting the vs code extension on par with the atom/proto-repl would be a good start

genec18:09:04

I'm thinking more about the project mgt, repl integration and debugging

ghadi18:09:08

I would love to see an implementation of the Language Server Protocol for clojure -- that is not tied to nREPL

ghadi18:09:09

(But certainly can reuse some of the nREPL functionality, just not the protocol) http://langserver.org/

ghadi18:09:11

Lots of tools (like VS Code or Emacs) are planning on implementing the language server protocol

ghadi18:09:17

(Atom, too)

genec18:09:04

interesting

turbopape18:09:12

just realeased version 0.3.0 of postagga, the easy natural language parser - now with more flexible parsing rule 🙂 https://github.com/fekr/postagga

mseddon21:09:51

@turbopape just glancing, it's not clear that you could handle unmarked passives, whiz deletion, gaps, pp attachment etc, using your approach, is that correct?

turbopape21:09:13

Oh yeah that’s true, it’s there just to get you going with extracting meaningful information from text whose structure is known

turbopape21:09:37

Just for you to write bots quickly

pflingstring21:09:09

Hello, I would appreciate a little help I created a luminus template with the +postgres option

mseddon21:09:11

Yeah, feels like Yale case frame parsers from the schank era. Definitely useful for a bunch of stuff still!

mseddon21:09:02

@turbopape do you have precision/recall for Brown Corpus POS and file size for the cljs tagger? Looking for a small tagger that can run in the browser but everything seems to be impractically large :(

turbopape21:09:08

Yeah I assume this is not the fanciest NLP methodology out there but it is there for the rest of us to use :)

turbopape21:09:06

You can use your corpus with it, shall be embeddable in your browser,

mseddon21:09:09

Nono, not a slight at all! Been feverishly studying oldschool semantic parsers and great to see things being done for humans :)

turbopape21:09:38

I tried a corpus on the browser

mseddon21:09:04

Problem with "compact" taggers i found you still need the corpus dictionary in the browser

turbopape21:09:25

Nor too bad performance-wise buy detection was poor

turbopape21:09:44

You can maybe lend a hand improving it :)

mseddon21:09:07

Or at least share notes. Seems we have similar hobbies :)

mseddon21:09:12

Sadly I don't have a small footprint solution to POS atm :)

turbopape21:09:32

Have you had a look at the ones I shipped?

mseddon21:09:17

I shall try them out tomorrow, thanks!

chalcidfly22:09:50

Is there a clojure library for emitting plain clojure?

chalcidfly22:09:17

Sort of along the lines of what Tim Baldridge does here, but more complete: https://www.youtube.com/watch?v=KhRQmT22SSg

bronsa22:09:44

emitting from what?

chalcidfly22:09:05

from Clojure to Clojure haha

bronsa22:09:10

tools.analyzer.jvm (the library that tim is talking about) has a pass that does that

chalcidfly22:09:23

Really? hmmm

bronsa22:09:43

(in fact, that's the pass that core.async uses from going from AST back to clojure code)

chalcidfly22:09:42

Not sure how I missed that, thanks a bunch!

bronsa22:09:46

tools.analyzer's documentation is not the best, my fault. contributions are more than welcome tho :)

chalcidfly22:09:08

pretty junior clojure guy here, but I’ll help if I see a way to

jmclavijo22:09:43

Does anyone know of a similar test structure to “are” in speclj?