Fork me on GitHub
#clojure
<
2016-09-09
>
didibus07:09:17

Can you run clojure inside slack like you can on the irc channel?

abdullahibra07:09:48

didibus i guess no, is slack API open for everyone?

htmldrum07:09:58

you could have a bot that evaluates clj

abdullahibra07:09:06

you need some bot to evaluate expression

am-a_metail08:09:35

@dominicm what is this magic?

dominicm08:09:50

/clj (map inc [1 2 3])

alexisvincent09:09:57

Hi guys. A real beginners question here. Im using cursive with intellij and trying to get some kind of hot reloading env setup.

(defproject natbox "0.1.0-SNAPSHOT"
  :description "FIXME: write description"
  :url ""
  :license {:name "Eclipse Public License"
            :url  ""}
  :dependencies [[org.clojure/clojure "1.8.0"]]
  :profiles {:dev {:dependencies [[org.clojure/tools.namespace "0.2.11"]]
                   :source-paths ["dev"]}})
this is my project.clj… I assume now that I need to make a cursive repl and specify the dev profile… But when I do, I get the following error
Error loading clojure.tools.nrepl.server: Could not locate clojure/tools/nrepl/server__init.class or clojure/tools/nrepl/server.clj on classpath.
Error loading complete.core: Could not locate complete/core__init.class or complete/core.clj on classpath.
Exception in thread "main" java.lang.ClassNotFoundException: clojure.tools.nrepl.server, compiling:(/private/var/folders/9s/txldqs4x1ts59q6qblrn133c0000gn/T/form-init6119612237788758823.clj:1:773)
	at clojure.lang.Compiler.analyzeSeq(Compiler.java:6875)
	at clojure.lang.Compiler.analyze(Compiler.java:6669)
	at clojure.lang.Compiler.access$300(Compiler.java:38)
	at clojure.lang.Compiler$LetExpr$Parser.parse(Compiler.java:6269)
        …
	at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)
Caused by: java.lang.ClassNotFoundException: clojure.tools.nrepl.server
	at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
	at clojure.lang.DynamicClassLoader.findClass(DynamicClassLoader.java:69)
        
	... 33 more

Process finished with exit code 1
Exception starting REPL: java.lang.InterruptedException

cfleming09:09:11

@alexisvincent Do you get that same error running lein repl on the command line?

cfleming09:09:39

Which OS are you using?

alexisvincent09:09:00

note this is when i specify in the repl config the profile dev.

alexisvincent09:09:12

running normally works perfectly

cfleming09:09:34

What do you mean by running normally?

hans09:09:13

does anyone know what i need to do to get support for the new ::foo/bar syntax that clojure.data.xml now uses? i've tried using clojure 1.9.0-alpha12 and it gives me "RuntimeException Invalid token: ::foo/bar clojure.lang.Util.runtimeException (Util.java:221)"

alexisvincent09:09:58

if i run ‘lein repl’ it works. Also, if I start the repl through cursive without specifying the dev profile it works

hans09:09:35

ah, never mind. i need to load clojure.data.xml to get a better message.

hans09:09:38

sorry for the noise.

alexisvincent09:09:04

Should I be specifying a profile when I start the repl ?

cfleming09:09:21

@alexisvincent If you do lein with-profile dev repl does that work?

cfleming09:09:22

@alexisvincent Sorry, lein with-profile +dev repl

cfleming09:09:48

Actually, in the Cursive run configuration are you putting dev or +dev?

cfleming09:09:38

You probably want +dev which will add that profile to the defaults, rather than dev which will replace the defaults with that profile only

alexisvincent09:09:24

@cfleming Thanks so much man +dev is what I wanted. Ok, so I assume theres ‘default’ profile? And you can merge profiles in? I’m really really new

alexisvincent09:09:19

@cfleming Your profile picture is brilliant. Ok, repl starts properly. But not sure its doing what I want it to. I have the following files in dev/ user.clj

(ns user)

(defn dev
  "Load and switch to the 'dev' namespace."
  []
  (require 'dev)
  (in-ns 'dev))
and dev.clj
(ns dev
  "Tools for interactive development with the REPL. This file should
  not be included in a production build of the application."
  (:require
    [ :as io]
    [clojure.java.javadoc :refer [javadoc]]
    [clojure.pprint :refer [pprint]]
    [clojure.reflect :refer [reflect]]
    [clojure.repl :refer [apropos dir doc find-doc pst source]]
    [clojure.set :as set]
    [clojure.string :as str]
    [clojure.test :as test]
    [clojure.tools.namespace.repl :refer [refresh refresh-all]]
    [natbox]))

(def system
  "A Var containing an object representing the application under
  development."
  nil)

(defn init
  "Creates and initializes the system under development in the Var
  #'system."
  [] (natbox.system))

(defn start
  "Starts the system running, updates the Var #'system."
  [])
  ;; TODO
...
am I right in assuming user.clj will be loaded automatically and then i can run (dev) and start developing?

cfleming09:09:15

I don’t use tools.namespace myself, but I believe so, yes.

cfleming09:09:33

Here’s the doc on profiles, it talks about adding, removing and defaults: https://github.com/technomancy/leiningen/blob/master/doc/PROFILES.md

cfleming09:09:11

If you’re really keen once you have that working, you can assign commands to keys like this: https://cursive-ide.com/userguide/repl.html#repl-commands

cfleming09:09:25

So then you can bind single keystrokes to the various reload commands.

alexisvincent09:09:21

@cfleming I have a working system now i think 🙂 awesome stuff. Thanks I’ll check that out. what do you use?

alexisvincent09:09:55

Is it necessary to run (dev). Or is there a way to automatically do it on startup

urbanslug09:09:55

Hey how can I write this regex #”{2}\w+” so that it makes sense in clj?

cfleming10:09:44

@alexisvincent I use Cursive, but I’m biased because I develop it 🙂

alexisvincent10:09:02

@cfleming haha. I see. Thats funny. I watched a talk of yours a yesterday. I mean you said you don’t use namespace

cfleming10:09:12

Oh right, I just use Cursive’s reloading capabilities. When I’m testing, I can’t easily just restart the app (since it’s a whole IntelliJ) so the reloaded pattern doesn’t work so well for me. When loading files Cursive does all the transitive loading that tools.namespace would do.

alexisvincent10:09:58

Oh interesting. Oh well. Going to go ahead and try get this going now

alexisvincent10:09:03

Thanks for the help 😄

bojan.matic11:09:18

In reading an old thread regarding the clojure compiler “single-pass” behavior (https://groups.google.com/forum/#!topic/clojure/x99HZ1KEcwE) I come across this:

bojan.matic11:09:25

> The world contains cyclic dependencies. Not all relationships are hierarchical.

bojan.matic11:09:07

can someone give an example of a valid use case for cyclic dependencies? I was under the impression that whenever you have cyclic dependencies between A and B, you have a C hidden somewhere that you need to extract

yury.solovyov11:09:43

you mean in real world or in code?

grav11:09:23

I get Error: Could not find or load main class geo.core when running java -jar geo-standalone.jar. I have added (:gen-class) to my geo.core-ns, and I’ve added

:main geo.core
  :aot [geo.core]
to my project.clj (I have no explicit profiles). I get no warnings when compiling. What can be wrong?

grav12:09:47

Scratch that, it seems that I supplied some other args that removed geo.core from the class path

adamkowalski17:09:28

Are there are any guides you all can recommend about how to design real time systems with clojure

adamkowalski17:09:33

I am traditionally used to a RESTful backend, but I think the push style model isn’t working for me, so I wanted to try something new. Rather then the client always asking for more information, I was hoping to use something like websockets so that I can simply inform the client that there is new data

adamkowalski17:09:30

Do you usually keep like a connected client pool, and then keep track of each clients subscriptions? Then as data is published you look for all the clients in the pool who want data of this type, pass it through your auth system to make sure they should be able to access it then send it over to the client?

pesterhazy17:09:30

is there a library for "redacting" data structures, i.e. making them easier to pretty-print? My use case if pretty-printing a huge nested map on the repl.

hiredman17:09:01

which pretty printer are you using?

hiredman17:09:10

I would guess that clojure.pprint respects *print-level* and *print-length*, but I am not sure

pesterhazy17:09:29

those look interesting

hiredman17:09:39

prn definitly respects those

hiredman17:09:01

but prn isn't really a pretty printer, it is just a printer

pesterhazy17:09:07

can you also supply a redact-fn for excessively large values?

Alex Miller (Clojure team)17:09:34

no, although it uses multimethods so you can override parts of it if desired

pesterhazy17:09:57

particularly in cljs, if you print a fn it prints the whole source code

Alex Miller (Clojure team)17:09:07

someone (probably Tom Faulhaber :) should write a small book about the Clojure print system

pesterhazy17:09:19

didn't know it was so powerful

Alex Miller (Clojure team)17:09:38

I think cl-format alone might be Turing complete :)

Alex Miller (Clojure team)17:09:09

I do not admit to understanding more than a fraction of it, despite having worked on it

jr17:09:43

@alexmiller are you waiting for a stable 1.9 before next core.async release?

Alex Miller (Clojure team)17:09:22

just haven’t been working on it

Alex Miller (Clojure team)17:09:32

@jr are you waiting for something in particular?

jr17:09:06

waiting for this commit to land and suppress a cljsbuild warning https://github.com/clojure/core.async/commit/43139e44b04dd09bb5faa555ea8ebd2ca09e25ce

jr17:09:16

obviously nbd just curious

mordocai17:09:46

@alexmiller cl-format is almost certainly turing complete assuming it actually matches the common-lisp format spec. It has conditions and loops.

mordocai17:09:04

Which I think is enough?

mordocai17:09:38

Hmm... not sure if it has "the ability to change an arbitrary amount of memory (e.g., the ability to maintain an arbitrary number of variables)."

pesterhazy18:09:27

@alexmiller, pprint/with-pprint-dispatch and`*print-length*` work perfectly for my use case, thanks!!

pesterhazy18:09:51

in cljs as well as clj. very impressive

richiardiandrea19:09:11

+1 for a core.async rev solving that warning 😉

Alex Miller (Clojure team)20:09:44

ok, 0.2.389 is out there now

Alex Miller (Clojure team)21:09:20

I’m probably not going to be super helpful debugging the cljs side - are you using a newish cljs?

jr21:09:13

Yes latest cljs. bounded-count is not defined for the cljs version but is being used

jr21:09:41

where I can see a definition for bounded-count in async.clj

Alex Miller (Clojure team)21:09:28

hmm. maybe it shouldn’t be excluded in cljs.

Alex Miller (Clojure team)21:09:41

yeah, looks like I screwed that up.

Alex Miller (Clojure team)21:09:10

stay tuned for core.async 0.2.391 :)

Alex Miller (Clojure team)21:09:01

it’s pushed, takes about 10 minutes to be available via maven central

jr21:09:07

awesome thank you

jr21:09:23

trying to determine how to-chan was working in cljs before bounded-count was added to core

Alex Miller (Clojure team)21:09:19

yeah, that is not obvious to me either

jr21:09:41

ah looks like bounded-count has been in cljs.core for awhile now

shader21:09:49

"#lobby" sounds like the name of a general discussion channel, rather than an admin-only messages channel

jr21:09:56

@alexmiller latest release looks good. cheers!

Alex Miller (Clojure team)21:09:40

thx, sorry for not getting it on the first try :)

seancorfield23:09:39

@shader: did you mean to post that in #community-development ?