Fork me on GitHub
#clojure
<
2016-10-04
>
mathiasx00:10:57

as-str seems to be doing the trick, because it just allows this string to become an HTML string. Makes sense.

seancorfield00:10:11

So many similar ways 🙂

a.espolov00:10:53

Guys, how to assoc key :abc/xyz to map?

quoll00:10:31

@a.espolov I don’t know if you’re asking something beyond the standard answer? (assoc the-map :abc/xyz some-value)

a.espolov00:10:16

@quoll: (assoc {} :amount/abc 123) => #:amount{:abc 123}

hjavaheri00:10:25

if you are in abc ns, you just need to (assoc the-map ::xyz the-value)

jrheard00:10:54

@a.espolov - that’s a new bit of syntax: #:amount{:abc 123} is the same thing as {:amount/abc 123}

a.espolov00:10:56

hjavaheri: mmm… custom namespace not available?

jrheard00:10:53

i’m trying to find a helpful link

hjavaheri00:10:33

This might help in the repl (set! *print-namespace-maps* false)

jrheard01:10:40

nice, hadn’t seen those links

Oliver George02:10:34

I'm finding it a bit fiddly to come up with good unique clojure.spec keywords when defining structured data. ::blah and ::my-alias/blah are helpful. I think it'd be useful to have ::anything/blah expand to :current-ns.anything/blah too.

jrheard04:10:27

i’ve found myself wanting the same behavior, @olivergeorge

jrheard04:10:55

i think that would be super super great

lfn308:10:27

So I know there’s a good way of handling macros that are like (defmacro do-stuff [config & body] …) but I can’t for the life of me remember what that pattern is or where I saw it. The issue is that config might actually be part of the body if it’s not a map or something that evals to a map, so I need to check that and maybe integrate it into the body…

hlolli10:10:54

it evals to a sequence, often you see `(fn [email protected]) if you want to splice the parenthesis.

danielgrosse11:10:43

Hello, do files which get reponsed via ring have to be in the resources path? Or how is it possible to get them from a location on the server?

hlolli12:10:58

@danielgrosse are you serving the files with ring? From you question sounds like you would be asking for something like http://www.facebook.com/../../../../usr/mark_zuckerberg/email_archives/nsa 🙂

danielgrosse12:10:42

@hlolli I just discovered, I could use (file "path/to/file.jpg") as response. So this is what I wanted.

mpenet12:10:03

you can use wrap-file with a dir also

hlolli13:10:34

Given that I need this in a macro (knowing this is not a problem in a defn), would this considered to be a bug or is there a way to avoid no matching ctor. compare this

(defn fn-returning-fn [a b]
  (fn [] (+ a b)))

(defmacro loop-in-macro [v]
  (loop [i v
         m {}]
    (if (empty? i)
      (prn m)
      (recur (next i)
             (assoc m
                    (ffirst i)
                    (eval `~(second (peek i))))))))

(loop-in-macro [[:a (fn-returning-fn 2 2)]])
=> prints: {:a #function[panaeolus.track-fn/fn-returning-fn/fn--21678]}
to this where I want to return the map
(defn fn-returning-fn [a b]
  (fn [] (+ a b)))

(defmacro loop-in-macro [v]
  (loop [i v
         m {}]
    (if (empty? i)
      m
      (recur (next i)
             (assoc m
                    (ffirst i)
                    (eval `~(second (peek i))))))))

(loop-in-macro [[:a (fn-returning-fn 2 2)]])
=> No matching ctor found for class
   panaeolus.track_fn$fn_returning_fn$fn__21710
(added: Im looking to get the same return value from the second example as is printed as side-effect from the first example).

cddr15:10:16

Anyone know why the default-fixture in clojure.test remains private? Seems like it would be useful when composing fixtures.

lvh15:10:29

Is there a way to tag a return value with a primitive using the ^’xyzzy

dialelo15:10:06

which primitive? long and double are supported AFAIK

dialelo15:10:30

and i believe the syntax is ^long

kaosko16:10:32

how can I reload my java code in a mixed clojure/java project? I tried reimport from https://github.com/zcaudate/vinyasa but ended up in a dependency hell with the current versions, now the project has been deleted. any other alternatives?

dvorme16:10:15

@kaosko : Choices I know of are (1) OSGi (probably with Apache Karaf) or (2) Wildfly.

dvorme16:10:09

OSGi doesn’t play very nicely with Clojure by default and the clojure.osgi project has gone unmaintained for quite some time now.

pesterhazy16:10:20

@kaosko there was a project that allowed you to do exactly that

dvorme16:10:24

If anyone else knows alternatives, I’m interested also.

kaosko16:10:17

looks like vinyasa is back (just now!) - seems like the author is moving stuff around

kaosko16:10:01

now that I see the vinyasa's changelog, I see he moved from pomegranate to wu.kong. they use a different version of aether which was causing a problem for me. I dropped back to using 0.4.3 vinyasa and I can confirm reimport is working now (lost the pull but oh well)

dvorme16:10:22

Here’s the most recently maintained clojure.osgi.utils as of the last time I checked: https://github.com/pmoriarty/clojure-osgi-utils

kaosko16:10:43

oh thanks @pesterhazy , haven't seen it, must try virgil right now. that's what I want (if it works...)

dvorme16:10:51

@pesterhazy Thanks; that’s nice.

kaosko16:10:38

perfect @pesterhazy, virgil works as expected. love you 🙂

grzm18:10:33

defmethod doesn't take a docstring, correct?

grzm18:10:54

I'm using multimethods for command dispatch and would like to document the different commands. I guess I could do this with the methods wrapping individual functions, but that seems like unnecessary duplication.

robert-stuttaford18:10:17

you could use the same dispatch values as keys in a docstring map

grzm18:10:20

Any ideas on alternative ways to approach or think of this?

robert-stuttaford18:10:25

that keeps it programmatic

robert-stuttaford18:10:31

or else use inline comments

robert-stuttaford18:10:28

or write very simple code, so you don’t need docstrings -grin-

grzm18:10:10

I appreciate the simple code idea 🙂 Sometimes it's hard to be succinct in naming attempting to explicitly describe what's going on 🙂

grzm18:10:29

Would you mind elaborating on the docstring map idea?

robert-stuttaford18:10:32

sure. if you needed programmatic access to docstrings, you could use the dispatch values you set up for your defmethods as keys in map, with values being your docstrings

robert-stuttaford18:10:04

(def yay-doc {:one “Totally serious work stuff here.”})
(defmethod yay :one [_ arg])

kidpollo18:10:28

I don’t want to have a flamewar here but is there some definitive place where the clojure indentation style is defined? I am particularly interested of what is the consensus for indentation of threading macros.

robert-stuttaford18:10:46

you’d still need to do extra work to get at the doc strings, but at least it’s deterministic

kidpollo18:10:24

does not specifically name thread macros tho

grzm18:10:46

thanks for the idea. Something to chew on.

robert-stuttaford18:10:31

cider lines the statements up vertically

robert-stuttaford18:10:55

whatever format you can automate into your editor wins, in my book

robert-stuttaford18:10:19

if you’re manually indenting code, you’re wasting precious time! 🙂

kidpollo18:10:32

there is a thread macro example but it does not specifically say

kidpollo18:10:52

I am not, just having a discussion with a co-worker

grzm18:10:06

@kidpollo I think you're right

kidpollo18:10:53

I’ll create an issue then

rhoslug19:10:04

noob question here, does anyone have a recommendation for an FTP library in Clojure?

robert-stuttaford19:10:50

for accessing ftp?

robert-stuttaford19:10:49

it wraps the Apache stuff, which about the best you’re going to do with minimal effort

rhoslug19:10:14

@robert-stuttaford yes, thanks, that is what I was looking for

misha21:10:34

@stbgz keywords here are intent to learn kappa

turbopape21:10:52

milestones, the smart project anagemet lib in #clojure, with #clojurescript support hits 0.2.0 ! https://github.com/turbopape/milestones

juliobarros23:10:14

A friend is facing problems with clojure on windows. Everything looks like it's installed correctly and lein reply on a fresh project works but changing the project to alpha13 causes a host of spec errors. No other changes were made on a new project. Any ideas?