Fork me on GitHub
#clojure
<
2016-03-24
>
Alex Miller (Clojure team)00:03:07

Anaphoric macros is prob what you're thinking of

Chris O’Donnell00:03:54

I'm running into some trouble getting an integration test for an app built around compojure-api. I wrote a custom exception handler which is invoked just fine if I trigger the error using curl or the swagger interface.

Chris O’Donnell00:03:24

However, when I call the handler inside my test, I know the exception is thrown, but instead of my error response, I just get nil.

Chris O’Donnell00:03:51

Any ideas would be much appreciated. I've been staring at this for a couple hours and am at a total loss.

hiredman01:03:21

I would check your routing, nil is what compojure routes return if they don't match

hiredman01:03:37

do you have a catch all 404 style handler in your routes? if you do and no other route matched you would get that response, not nil, if you don't you definitely could be getting nil because a route is matching like you think it should

Chris O’Donnell01:03:56

@hiredman: Thanks, I'll doublecheck routing.

Chris O’Donnell01:03:31

@hiredman: Yep, that was it. Thank you very much! Hopefully next time it won't take me this long to notice the missing "/". :face_with_rolling_eyes:

hiredman01:03:59

maybe stick in a 404 handler that will make it more obvious

Chris O’Donnell01:03:28

I will definitely do that.

kenrestivo04:03:51

i've just taken a job at a shop that has a "NO JAVA ALLOWED" rule. that means no jvm either, and that means no clojure.

kenrestivo04:03:11

they also frown on node too, so no clojurescript either.

kenrestivo04:03:34

so i suppose my options to use clojure at all are maybe cljs on v8

cky04:03:12

@kenrestivo: …so what do they use? PHP?

kenrestivo04:03:24

python and erlang

cky04:03:18

I’d like to see Clojure on the Erlang virtual machine. But I’ve said that for many years. Just ask @bridget. 😛

kenrestivo04:03:57

it would not be a small project, i expect. elixir might be interesting once it matures though.

kenrestivo04:03:17

but clojure on the BEAM would be very nice indeed

bijoy04:03:56

may be a chance to play with lisp flavored erlang http://lfe.io/ 😉

cky04:03:59

Indeed! (And please nobody mention LFE; it’s not Clojure.)

cky04:03:57

What I mean by “it’s not Clojure” is this: one of the biggest value proposition for CLJS is that you can write common libraries that can be used by both Clojure and CLJS simultaneously. That kind of code reuse isn’t possible for LFE (to my knowledge), so.

cky04:03:30

In the same way that a Big Feature of having JS libraries in npm is that the code is usable both in Node and for frontend stuff via Webpack/Browserify/etc.

kenrestivo04:03:55

wait, wasn't that tim's project?

kenrestivo04:03:07

the guy who wrote the go macro in clojure?

kenrestivo05:03:05

that's the one that tim did, thanks. both look interesting, will try, thanks

urbanslug05:03:38

Does a project try to fetch itself from clojars when a plugin is run?

urbanslug05:03:48

e.g attempting to run lein bikeshed on lein bikeshed gives me errors regarding not finding my local (on disk) of lein bikeshed in clojars

hiredman05:03:16

are you sure you have a copy of lein bikeshed on disk? are you using a snapshot version?

hiredman05:03:39

if I had to guess it isn't lein bikeshed that is throwing an error, but just lein

hiredman05:03:24

so lein is seeing the lein-bikeshed plugin and trying to find it and can't

urbanslug06:03:47

Yes lein is throwing the error

urbanslug06:03:35

But it’s trying to fetch a version of lein bikeshed that I didn’t ask it to

hiredman06:03:48

why do you say that?

urbanslug06:03:11

@hiredman: Because I keep getting Could not find artifact lein-bikeshed:lein-bikeshed:jar:0.3.1-SNAPSHOT in clojars

urbanslug06:03:33

Ok this is what’s up. I cloned this https://github.com/dakrone/lein-bikeshed

urbanslug06:03:48

Then cd lein-bikeshed

urbanslug06:03:02

Then ran lein bikeshed in it and failed.

urbanslug06:03:15

Mind you I have just deleted my ~/.m2

urbanslug06:03:25

This is in my profiles.clj

{:user {
 :plugins [[cider/cider-nrepl "0.11.0"]
           [refactor-nrepl "2.2.0"]]
 :dependencies [[org.clojure/tools.nrepl "0.2.11"]]
 }}

urbanslug06:03:21

I wonder whether it’s causing a conflict because of:

lein deps :tree
Warning: refactor-nrepl requires org.clojure/clojure 1.7.0 or greater.
Warning: refactor-nrepl middleware won't be activated due to missing dependencies.
Warning: refactor-nrepl requires org.clojure/clojure 1.7.0 or greater.
Warning: refactor-nrepl middleware won't be activated due to missing dependencies.
Possibly confusing dependencies found:
[org.clojure/tools.nrepl "0.2.11"]
 overrides
[cider/cider-nrepl "0.11.0"] -> [org.clojure/tools.nrepl "0.2.12" :exclusions [org.clojure/clojure]]

Consider using these exclusions:
[cider/cider-nrepl "0.11.0" :exclusions [org.clojure/tools.nrepl]]

 [cider/cider-nrepl "0.11.0"]
   [org.tcrawley/dynapath "0.2.3" :exclusions [[org.clojure/clojure]]]
 [clojure-complete "0.2.4" :exclusions [[org.clojure/clojure]]]
 [org.clojure/tools.cli "0.3.1"]
   [org.clojure/clojure "1.4.0"]
 [org.clojure/tools.namespace "0.2.6”]
 [org.clojure/tools.nrepl "0.2.11”]

hiredman06:03:00

I don't think you can do that

hiredman06:03:26

run a lein plugin from a check out of itself from lein

hiredman06:03:26

if you want to run bikeshed you'll need to add it to :plugins

dottedmag11:03:40

Does REPL bind results of recent evaluations to some symbols? Something like $3 to refer to the result of evaluation three commands back.

schmir11:03:57

*1, *2, ...

schmir11:03:06

*e for the last exception caught

pesterhazy11:03:17

So

(future (Thread/sleep 1000) (println (/ 1 0))
never throws an exception if you don't deref the future. Is there an easy, fire-and-forgot abstraction like a future that triggers the default exception handler? I don't care about the result of the call.

steven_t12:03:46

hi, can someone help me with a wrong namespace in my clojure? I'd like clojure-update-ns to put the correct ns in.

steven_t12:03:39

I run leiningen 2.6.1, SpaceMacs and am trying some code in an new empty project created with lein new app

borkdude12:03:59

@steven_t: gist or github project?

steven_t12:03:17

no, just an empty project. had trouble auto setting the ns in another project so just started a new one to test this.

steven_t12:03:08

I open a new file in src/app/main.clj and add (ns bla), run clojure-update-ns and get: (ns ......Repositories.clojure.myapp2.src.myapp2.main)

borkdude12:03:45

the ns should reflect the directory structure

borkdude12:03:59

I have no idea what clojure-update-ns does

steven_t12:03:14

how is the root found? the path is correct, just from the wrong base

borkdude12:03:49

what is clojure-update-ns? something from your editor?

steven_t12:03:33

yes, it is available in emacs.

borkdude12:03:25

never used that function, I'm sorry

borkdude12:03:39

@steven_t if it's CIDER related you could try in #C0617A8PQ

steven_t13:03:07

ah, ok. thx. will see if it is in cider.

Jon13:03:29

Anyone using boot? I got this error message trying to build jar files..

martinklepsch13:03:45

@jiyinyiyong: there's a #C053K90BR channel

pesterhazy13:03:47

@jiyinyiyong: can you share your build.boot?

martinklepsch13:03:07

looks like you're passing something to an option that expects something diffferent simple_smile

pesterhazy13:03:11

there's a syntax error in the file

thiagofm13:03:57

Anybody has any clojure project that needs maintaining? I couldn't find any channel for people who wants to contribute(Perhaps it's a good idea to start one?)

nielsk13:03:36

List of active projects looking for contributors: http://open-source.braveclojure.com/

jetmind13:03:47

Hi everyone! We're planning on moving our Rails app to Clojure and would want to keep our Rails templates during the transition time. Is there a way to render Rails templates in Clojure (or Java)? The reason we need this is because templates will probably change at the same time as transition happens and we don't want to update them in two different places/templating languages. Eventually we'll switch to Clojure templating library completely, of course. Or it isn't worth the effort and we should just rewrite templates to Clojure from the beginning and deal with duplication? Thanks for your thoughts.

petterik13:03:11

I'm getting "Wrong number of args (-1) passed to:" when calling a declared macro from a function. Smallest case I can replicate with is this: https://gist.github.com/petterik/dfe3d7de04c3bf770b26 Using Clojure 1.8. Has anyone else seen this? What can be done?

nielsk13:03:35

Just saw it announced on the clojure gg this morning simple_smile

thiagofm13:03:53

@nielsk: what is clojure gg?

nielsk13:03:02

google groups

moxaj13:03:08

@petterik declare the function, and define the macro first, then the function. Declaring a macro does not seem to work, I have no idea why.

bronsa13:03:18

declaring a macro doesn't make sense. macroexpansion happens at compile time, you can't retroactively macroexpand

bronsa13:03:42

it's the same as if you'd expected

(declare foo) (foo) (defn foo [] 1)
to work

nielsk13:03:51

@petterik That's not a macro, is it ? Macro's take their parameters and generate a list of code that's executed afterward

nielsk13:03:18

(declare fail) (defn fail* [m] (if (map? m) (fail 1) m)) (defmacro fail [m] `(if (map? ~m) (fail* ~m) ~m)) (fail 1)

moxaj13:03:28

@nielsk they can return anything to be evaluated

moxaj13:03:56

@nielsk but the computations would happen at compile time

bronsa13:03:23

wrt the -1 arity exception, that's actually a known bug http://dev.clojure.org/jira/browse/CLJ-1279

petterik14:03:04

Makes sense @bronsa. Thanks

razum2um15:03:51

could someone explain why these lines are needed https://github.com/ninjudd/classlojure/blob/master/src/classlojure/core.clj#L81L86 ? I tried to return just result (not a java core class) and it worked

lvh16:03:15

In lein project.clj files, is there a way to refer to parts of the project map that is transparent to plugins? Specifically; I’m trying to get @weavejester’s lein auto to also watch resources/. By default it only watches Clojure source paths, Java source paths and test paths. However, I would prefer to specify that I only want to add the resources path, and, if that is not possible, at least specify a reference to some value in the project map so I don’t repeat e.g. the resource path several times in project.clj

keymone16:03:51

what is the idiomatic way to do blocking dequeue in clojure?

lvh16:03:31

keymone: as in deque/double ended queue?

lvh16:03:58

keymone: clojure.lang.PersistentQueue

keymone16:03:53

@lvh does pop block on PersistentQueue until something is queued?

lvh16:03:28

keymone: ah; that’s a good question, I don’t remember offhand

keymone16:03:49

i think it doesn’t, docs say it raises exception if collection is empty

lvh16:03:27

keymone: Have you considered core.async? That does have blocking channels.

lvh16:03:41

keymone: And if you don’t really want blocking but maybe want fake blocking, my favorite async lib is manifold

keymone16:03:11

i’ll probably use async, yeah

bostonaholic16:03:01

@lvh: would something like :auto {:default {:paths [:source-paths :java-source-paths :test-paths "resources/"]}} work?

bostonaholic16:03:21

or whatever task you're using

lvh16:03:51

bostonaholic: Nope; I tried that

lvh16:03:54

java.lang.IllegalArgumentException: No implementation of method: :as-file of protocol: #' found for class: clojure.lang.Keyword

weavejester16:03:19

lvh: Just to be clear… you want lein-auto to refer to paths already set in the project file?

lvh16:03:52

weavejester: Well, ideally I want lein auto to refer to the paths already set in the project map, i.e. correctly work with profiles

lvh16:03:30

weavejester: What I really want to accomplish is for lein auto to start watching my resources path 😉 but ideally my lein auto configuration doesn’t duplicate where sources live, java sources live, &c

weavejester16:03:15

So you’ve got it working, but the problem is that you’re duplicating data?

weavejester16:03:17

Specifying the paths in both :resource-paths and :auto {:paths …}, for instance?

lvh17:03:06

right; I can get it working sorta by duplicating the paths

lvh17:03:17

and then duplicating the entire :auto map for profiles where some paths change

lvh17:03:24

it works, it just isn’t very pretty simple_smile

weavejester17:03:51

lvh: Ah, I see the problem.

weavejester17:03:15

I think I’d accept a patch where keywords would be substituted for their equivalent values.

lockdown17:03:38

For speed of development and for building a crud website with server side rendered pages (form, databases, use auth), would any of you really choose Clojure instead of something like nodejs ? (or even rails)

weavejester17:03:19

I know Clojure’s web libraries fairly well, so personally I’d be faster with them simply due to familiarity.

weavejester17:03:53

However, someone who already knows Rails, and is only concerned about getting something out as quickly as possible, is going to be faster with Rails I suspect

wamaral17:03:31

for the first week, or month maybe

weavejester17:03:31

I see Clojure’s strength as being able to marathon rather than sprint.

weavejester17:03:09

The problems I’ve had writing web apps hasn’t come at the beginning

weavejester17:03:29

But in the middle when the code is getting twisted up and complected.

felixflores17:03:49

@lockdown: there is this… http://www.luminusweb.net but I personally like building my stuff one component at a time

weavejester17:03:16

I like component as well, which is why I put together Duct simple_smile

felixflores17:03:28

oh nice! this is my cup of tea @weavejester

lockdown17:03:02

new to the ecosystem but I'll give a small project a try, I guess for small stuff it doesn't really matter much, but as all of you said, you get more flexibility with time

lockdown17:03:17

weavejester: do you plan to add any auth stuff to that lein template? 😄

weavejester17:03:17

lockdown: I’m being pretty conservative with it so far. I don’t want to add something, then later change my mind about it, because templates are hard to change after they’ve been used.

seancorfield17:03:50

We’ve used a mix of CFML and Clojure very successfully for web applications — CFML for the framework / Controller / View portion and Clojure for the Model. We’re moving to Clojure Controllers at this point and, where we’re not generating complex views, we’ll move to Clojure full stack over time.

weavejester17:03:50

lockdown: So maybe eventually, but there’s a lot I want to do before then.

lockdown17:03:55

seancorfield: what is CFML?

lockdown17:03:22

weavejester: what kind of stuff?

weavejester17:03:17

lockdown: Well, the generators need an overhaul. I think I might just make them into functions, since Duct is designed to have a REPL open anyway, and running a function in a REPL is faster and possibly more convenient.

weavejester17:03:49

lockdown: I also want to add some .dirlocals.el file to the locals generator, so that ClojureScript and Reloaded works with Cider out of the box.

weavejester17:03:29

lockdown: And I’m thinking about formalising my ideas around “boundary protocols”.

lockdown17:03:26

weavejester: nice stack, all the web libraries I have hear from Cloure, all by you simple_smile, comparing it to luminus looks more simple and organized to me

weavejester17:03:48

Luminus I think is simpler to get started with, maybe?

lockdown17:03:49

weavejester: (not that I needed) is that stack async?

lockdown17:03:06

weavejester: I like how you took the component approach

weavejester17:03:45

Duct uses Ring, which isn’t natively async, but you can use servers like http-kit which have async support.

weavejester17:03:26

I’m working on an application that uses websockets heavily. It doesn’t use all of Duct, but a good deal of the components I developed for Duct I share with this app.

lockdown17:03:59

weavejester: from your readme I could see what duct does pretty quickly from luminus not so much

weavejester17:03:32

Thanks for the vote of confidence in the docs.

lockdown17:03:38

weavejester: oh I see, do you have plans for an async Ring or you want to leave to other web servers?

weavejester17:03:27

Well… I started writing Ring-CPS, which is async with continuation-passing-style. But then I realised there’s no common async I/O between webservers, except maybe with callbacks.

weavejester17:03:38

So I’d essentially need to write an NIO abstraction

weavejester17:03:01

So I shelved the project for now. I might come back to it later.

weavejester17:03:17

I tend to be sporadic in which projects I work on.

weavejester17:03:35

On the subject of Duct, I have a presentation I need to link from the README: https://skillsmatter.com/skillscasts/7229-duct-covered

seancorfield17:03:46

@lockdown: CFML = ColdFusion Markup Language — which is really a misnomer these days since it’s more a compile-on-demand dynamic scripting language (like JS but on the JVM). We’ve used a FOSS implementation for years (Lucee, formerly Railo).

lockdown17:03:03

weavejester: ok, jetty is very fast anyway

lockdown17:03:30

weavejester: what did you use for websockets?

weavejester17:03:33

lockdown: My view is that async just complicates most applications. If you don’t need async, blocking is easier to reason about.

weavejester17:03:41

lockdown: http-kit

seancorfield17:03:27

Back in 2009, I wrote a lightweight MVC framework for CFML (that became one of the two most popular MVC frameworks in CFML) and I ported it to Clojure and that’s what we’re using at World Singles — both the CFML and Clojure versions 😸

lockdown17:03:52

weavejester: so with ring/jetty, jetty just spawn multiple threads and one connection per thread is used right?

weavejester17:03:03

lockdown: Right.

hiredman17:03:30

strictly speaking it uses a threadpool

weavejester17:03:51

Yeah, there’s a threadpool.

lockdown17:03:00

weavejester: cool, is compojure more oriented towards server side rendered pages than for a http api?

weavejester17:03:29

lockdown: Compojure doesn’t care. It just handles routing.

lockdown17:03:59

I like how Clojure is fast, so for this computationally intensive little project will suit better than ruby or nodejs

lockdown17:03:55

nothing really serious, I'm new to all this stuff, having know scheme, clojure is attractive 😉

lockdown17:03:38

weavejester: I asked about compojure because found this compojure-api lib while search for compojure

weavejester17:03:07

compojure-api is build on top of compojure and made for building restful APIs

weavejester17:03:27

I didn’t develop it, though.

weavejester17:03:36

Or have used it before simple_smile

weavejester17:03:43

So I can’t tell you much about it.

lockdown17:03:40

weavejester: do you know why they did add bi-directional routing?

juhoteperi17:03:54

@lockdown: If you have questions about Compojure-api we have channel #C06GSN6R2 for talk about Compojure-api and other libs using Ring-swagger. Also you can just ask here as me and Tommi have highlight set to "compojure-api".

weavejester17:03:25

lockdown: I guess because it’s useful, particularly for APIs that place a lot of emphasis on URLs.

juhoteperi17:03:28

@lockdown: I don't know how to answer to that 😄 Maybe because we could?

juhoteperi17:03:52

Routes in Compojure-api have metadata so we can use that metadata to give a name to a route and use that for "reverse routing"

lockdown17:03:55

weavejester: deraen: ok, I'll study this further instead asking dumb questions, new to web stuff, and studying my alternatives 😉 was just wondering why one had this feature and on the other not

lockdown17:03:26

deraen: I guess this helps with hypermedia stuff I have been reading of lately right?

lockdown17:03:38

de_youri: hateous

lockdown18:03:05

err deraen ^

weavejester18:03:54

Compojure doesn’t because I don’t like leaky abstractions. I’d explain more… but I need to go now, I’m afraid simple_smile

lockdown18:03:15

weavejester: no worries, thank you for you time! really helped

weavejester18:03:29

No problem. Bye!

juhoteperi18:03:35

@lockdown: Yes, if will be helpful if you want to create urls to other routes inside your backend app. Honestly, it is not something I have used much myself.

lockdown18:03:28

deraen: is it only meant to work with http-kit?

juhoteperi18:03:42

@lockdown: Compojure-api should work with any Ring compatible server. At Metosin we are using aleph, http-kit and jetty.

lockdown18:03:28

hmm the weavejester's talk is behind a log in

lockdown18:03:25

deraen: does Metosin uses it mostly for SPAs?

juhoteperi18:03:13

@lockdown: Yes. Mostly with SPAs, but often the backend also exposes some routes for third party applications for integrations.

adamkowalski18:03:44

so after having experience with those three servers, do you have a preference one way or another?

juhoteperi18:03:55

Not much. Mostly the differences are with using websockets. Aleph and Http-kit are nice both.

adamkowalski18:03:39

Aleph has its own abstraction over websockets right?

adamkowalski18:03:58

Is there anything that uses core async channels to talk over websockets?

juhoteperi18:03:10

Chord works with Http-kit and Sente should work with multiple servers

adamkowalski18:03:45

thanks, I will check both of those out

fommil19:03:30

is it possible to use/require all the dynamic variables in a ns but not the functions? (without explicitly listing them)

fommil20:03:30

how can I get documentation like http://clojure.github.io/core.async/ served up locally when I'm offline?

rickmoynihan20:03:53

you could write a function to do it - but you'd have to require that then call it

fommil20:03:56

cider is great for search for docs of a function I know, but not browsing what's available

fommil20:03:05

the use case is that I'm learning clojure and I want to be able to explore the stdlib and the key libs I'm depending on

fommil20:03:13

@bronsa isn't that for my project? Not the dependencies

bronsa20:03:38

@fommil: well, I was suggesting you could clone your dependencies and run autodoc on them simple_smile

fommil20:03:03

@rickmoynihan: cool, this is interesting

bostonaholic20:03:39

there is also clojure.repl/apropos

bostonaholic20:03:00

(which is included by default when you spin up cider)

bostonaholic20:03:26

user> (apropos "transact")
(datomic.api/transact
 datomic.api/transact-async
 datomic.connector/create-transactor-hornet-connector
 datomic.coordination/lookup-compatible-transactor-endpoint
 datomic.coordination/lookup-transactor-endpoint
 datomic.memory/aws-transactor-settings
 datomic.memory/transactor-cache-bytes
 datomic.memory/transactor-settings
 datomic.peer/transact
 datomic.peer/transact-all
 datomic.peer/transactor-endpoint
 datomic.peer/transactor-unavailable)

borkdude20:03:19

@fommil: the documentation is in your ~/.m2 folder. you can browse jar files with emacs just fine simple_smile

borkdude20:03:50

(if offline that's what I did sometimes)

fommil20:03:15

@bostonaholic: I did (apropos "async") and it found some obscure methods with async in the name, didn't pick up on the package

fommil20:03:03

@borkdude yeah, but that's source. It's nice to explore things as docs

fommil20:03:13

a less graphical clj-ns-browser would be ideal

borkdude20:03:21

@fommil: also there is Dash. I don't use it a lot, but I just started it and found I have some core.async docs in there. https://www.dropbox.com/s/llsy922v8f7e7rr/Screenshot%202016-03-24%2021.12.43.png?dl=0

borkdude20:03:53

@fommil: in emacs I can also go to a definition with M-. and look up the docs there

fommil20:03:33

@borkdude I have that too, but it's not doc browsing. The usecase is about sitting back and seeing *what* is available, not how it does it.

borkdude20:03:24

OK. Then ~/.m2, Dash or this: https://www.httrack.com/

fommil20:03:31

being able to see the ns broken down and letting me browse the functions, that's very useful. Even better if package / jar -level docs are available to explain a thing. I suspect I'll struggle with midje when I'm offline

fommil20:03:44

interesting, I wonder if that works for the midje docs (which I should clone anyway)

borkdude20:03:32

I usually used it like this: httrack -O om-wiki -n

borkdude20:03:44

for for example browsing the Om documentation offline

borkdude20:03:54

I did this when commuting

nkraft20:03:15

@borkdude: How does that compare with using wget -M? That's what I usually use for offline mirroring.

borkdude20:03:30

@nkraft: I have never tried wget -M, it might work just as well

borkdude20:03:46

@nkraft: I would like to include external CSS, images etc, if one level deep

borkdude20:03:11

@nkraft: that's what httrack does for me, with rewriting of relative urls if needed, those kinds of things I guess

nkraft20:03:51

@borkdude: Wget does all that, and a lot more. wget --help is a good rundown. I've been using it to mirror sites, converting links along the way. It can also take a regex to exclude or include urls. It's pretty cool, especially in scripts. I'll have a look at httrack too to see what else it might do.