Fork me on GitHub
#clojure
<
2016-07-12
>
danburton01:07:58

(As it turns out, there's bidi/unmatch-pair which accepts the params in a map.)

gowder02:07:05

Thanks @jsa-aerial --- looks like worth an experiment or two...

oboff03:07:34

how can I provide a default value for an expression that returns nil? (second '()) ; instead of nil return a default value of 1

Chris O’Donnell03:07:34

@alexmiller: I am planning on creating a protocol to define the interface for my database. For testing purposes I want to mock small bits of functionality. Since reify doesn't require me to implement all of the methods of a protocol, I'll probably use that to mock necessary functions.

Chris O’Donnell03:07:09

I thought I would need to provide implementations for each protocol method, but it seems that is not the case.

jr03:07:13

@oboff: or? (or (second ‘()) 1)

benzn06:07:47

hi folks, i've been writing a lot of clojure lately w/in lein projects and am curious about the most optimal layout of everything

benzn06:07:04

i'd like to be able to have a bunch of different lein projects and then seamlessly include them in others

benzn06:07:13

without having to manually build a bunch of jars and whatnot

benzn06:07:35

is there some way to specify lein dependencies by path?

benzn06:07:45

i currently end up jamming everything into one project which feels... gross

Macroz06:07:54

I tend to use that for the few dependencies to my own libraries

Macroz06:07:09

once their versions have stabilized I typically stop using them as checkouts

benzn07:07:14

perfect, this looks exactly like what i want, thanks!

benzn07:07:32

and i would've never thought to call this / search for "checkout dependencies"

benzn07:07:37

clojurians strike again 🙂

Macroz07:07:22

Great! The name maybe unfamiliar but It is documented in the tutorial.

jh39807:07:40

is it possible for a map to store a value that's generated by a function everytime it's accessed? (def m {:a #(rand 10)})

jh39807:07:58

so (:a m) should generate a random value everytime?

jh39807:07:27

instead of doing ((:a m))

mpenet07:07:34

jh398: nope, but potemkin has something similar: see def-derived-map

Macroz07:07:12

what is the reason that it should be a map in the first place?

mpenet07:07:40

yeah reaching into such solution often indicates something hairy upstream

Macroz07:07:58

maps should be values

jh39807:07:49

yes, i am just curious to whether this is doable in clojure

Macroz07:07:18

you can implement the same interfaces but not distort the existing map

Macroz07:07:56

most likely you want to refactor to something entirely different

jh39807:07:38

@macroz i am using the component library, and i would like my component to return a fresh resource everytime someone else calls (:resource component)

jh39807:07:19

so it looks more idiomatic instead of ((:resource component))

Macroz07:07:32

I don't use it myself but sounds awfully wrong 🙂

jh39807:07:23

yes it doesnt feel right, but not sure how else to do it at the moment...

jh39807:07:33

just started doing clojure for a month or so

Macroz08:07:11

sounds to me that you are storing a factory, not a resource

Macroz08:07:35

it would be obvious then that to create a new resource you need to invoke the factory

jh39808:07:51

yes thanks

jh39808:07:03

(:resource-factory fn) makes more sense

mccraigmccraig08:07:19

if you are just after the keyword lookup pattern @jh398 then you can implement ILookup ... maps implement a whole bunch of other interfaces too, which it doesn't sound like you need

Macroz08:07:03

I think here a regular map is fine and the unintuitiveness goes away with the rename

jh39808:07:00

@mccraigmccraig: reimplementing ILookup means it will affect all map access right? seems a bit risky for my usecase?

mccraigmccraig08:07:53

it wouldn't be a map without a whole bunch more impl, but it would do whatever you want for (:foo thing)

jh39808:07:36

ok thanks

rickmoynihan09:07:15

At the moment clojure doesn't have good support for Java 8 streams - which is problematic when java api's adopt this abstraction.... I realise the core team haven't yet got a position on streams; but I'm wondering if there's any speculation on how they might best be integrated into clojure.core (if at all?). In particular I'm wondering whether they'd most likely be supported through transducers

rickmoynihan09:07:03

Or is the answer likely to be use a 3rd party api... e.g. https://github.com/ajoberstar/ike.cljj

dominicm09:07:24

@rickmoynihan: Why is clojure.core support needed for them?

rickmoynihan09:07:14

Well it's not needed as it can be covered by API's (as above) - but many approaches lead to fragmentation - and that damages interop. Historically clojure has always had amazing access to java...

dominicm10:07:07

@rickmoynihan: I'm not a java guy, but I'm interested in java 8 streams somewhat, but I don't fully understand what might have been added that Clojure can't interop with.

dominicm10:07:52

The sams in ike.cljj, look more like they should be implemented by having functions extend the SAM class. This might be off the mark though.

dominicm10:07:09

Oh, you need to be able to say "this is a predicate". I find this strange (on the java side, although I see the utility). 😛

rickmoynihan10:07:06

I used to be a java guy, but got out at about java 6... so only have a cursory knowledge of what was introduced in java 8... Basically an API I use from clojure has started releasing builds for java 8 - that use streams instead of iterators etc... so at some point I'll need to port our code to work with it

rickmoynihan10:07:26

And I'd rather back the winning horse 🙂

wotbrew10:07:17

Quick question: Do we have the ability to alias a namespace purely for keywords? i.e without loading a file?

peeja15:07:50

@danstone: I'm not sure if it's a terrible practice, but you can (clojure.lang.Namespace/findOrCreate 'some.namespace) and then alias it. If you have namespaces you never intend to have actual code and only use for naming keywords, that may be a workable solution (at least until there's a real solution in the language).

peeja15:07:15

Has anyone come up with a way to hang docstrings on specs? I'd like to spec a function and give each arg a docstring, and then recover those docstrings later from the result of conforming args to the spec.

peeja15:07:41

Or, more generally speaking, I'd like to hang metadata on the nodes of a spec

peeja15:07:44

Maybe I want some kind of registry by tag keyword? But the keywords used as tags in specs are unqualified in all the docs, so I'm not sure that would work.

Alex Miller (Clojure team)16:07:29

Adding docstrings to specs is still under consideration

Alex Miller (Clojure team)16:07:24

Not sure many people noticed but doc will now look up a spec if you pass it a qualified keyword

Alex Miller (Clojure team)16:07:37

That could potentially also report a docstring

donaldball16:07:30

I would quite like the ability to add a body to the generated docstring for e.g. a keyword spec, giving some guidance as to the intended use

tel17:07:31

it looks like alpha9 removed :clojure.spec/any—is there any documentation on this decision?

tel17:07:43

What should be used in its place?

tel17:07:27

and also I meant alpha10 anyway 🙂

danburton18:07:11

Neat. So basically (def any? (constantly true))? Except with generator support.

iwillig18:07:01

On this page http://dev.clojure.org/display/design/Never+Close+a+REPL Stuart mentions that reloading multimethods is an issue. I have noticed in the past that the new impl of multi methods are not used until a hard restart. Do people know if this is still an issue? Is this something solved by tools.namespace. Thanks

joelkuiper18:07:58

Released the first version of clj-similar https://github.com/vortext/clj-similar it’s /very/ experimental but feedback is most welcome (although I’ll admit the specific use case I made it for won’t be all that common)

dg20:07:38

Returning detailed results through meta-info is interesting

joelkuiper21:07:58

@dg I don’t think it’s very idiomatic, but in this case it really is “meta data” in my opinion, and you’re very often not really interested in it

seancorfield23:07:18

…and that’s Clojure 1.9.0 Alpha 10 in production now! 🙂