Fork me on GitHub
#clojure
<
2015-08-10
>
ericnormand02:08:43

I implemented microKanren over the weekend

ericnormand02:08:10

it made me wish that maps were defined recursively like lists are

ericnormand02:08:23

I guess I mean that the tree structure is apparent

ericnormand02:08:38

for instance (cons 1 x) is just a constructor

ericnormand02:08:59

but (assoc x :a 1) does some behind-the-scenes magic

ericnormand02:08:11

the tree of the map is not revealed

ericnormand02:08:58

still, microKanren is very cool and I recommend it

robert-stuttaford11:08:51

anyone have experience listing files in a subfolder in a jar?

robert-stuttaford12:08:31

in a way that works both inside a jar and outside. currently (-> “path” io/resource file-seq) isn’t doing it

robert-stuttaford12:08:42

really would like to avoid (JarFile.) and friends

greywolve12:08:11

would this do the trick? @robert-stuttaford

robert-stuttaford12:08:44

i suppose i could use that and filter it with regex. but this’ll be happening in an uberjar where LOTS of files will be on the classpath

robert-stuttaford12:08:33

ah, that lib appears to handle that

borkdude14:08:14

I have a weird problem. In IntelliJ I see the namespace ring.middleware.not-modified. Also I get autocompletion for it in Emacs. Yet my code results in an error about the class not being found.

st14:08:39

Hello @borkdude, lein uberjar works fine in a terminal? lein clean and lein check may help you.

borkdude14:08:49

@st thanks, I'll try

shamatov14:08:25

Hello everyone

shamatov14:08:59

I've decided to start learning clojure. Could anyone advice me some way?

shamatov14:08:13

I'm writing ruby/rails for already 5 years, clojure is complitelly different.

borkdude14:08:06

@shamatov: Read a book and exercise with 4clojure + do a web application in clojure

shamatov14:08:07

At first I tried to find everything similar, like rake-lein or rack-ring

borkdude14:08:48

@shamatov: First learn the basics of the language

shamatov14:08:12

@borkdude: ok, 4clojure, thanks!

cfleming15:08:53

@borkdude: I assume you get the same error using lein repl?

borkdude15:08:33

I just opened IntelliJ to see if the dependency was there

cfleming15:08:09

Yeah, that’s a very strange error

nberger15:08:47

@borkdude: is the dependency in lein with-profile uberjar deps :tree?

borkdude15:08:08

@nberger: why uberjar if I may ask?

jeffh-fp15:08:18

@shamatov: join #C053AK3F9

nberger15:08:16

hmmm I saw uberjar in the stacktrace, but now I see it's just one of your .clj files... nvm then

jeffh-fp15:08:17

@shamatov: some suggestions:

Clojure for the Brave and True
Clojure from the Ground Up
Light Table, , and a few of Rich Hickey's talks, 4Clojure and Clojure Koans
Living Clojure is another book, by the same author as How I Start Clojure - 

nberger15:08:27

But if the issue was happening when running from your uberjar, the with-profile uberjar would help to see if the ring jar was being excluded from your uberjar somehow

shamatov15:08:28

@jeffh-fp: thanks, put in memories.

nberger15:08:57

@borkdude: do you have :aot matchmaker.uberjar or :main matchmaker.uberjar? If yes, can you try removing it?

borkdude15:08:37

@nberger: I have that and I'll remove it, see if that does anything

nberger15:08:38

@borkdude: Cool, let us know. Also as others said, be sure it's not a caching issue: lein clean but why not also manually clean in ~/.m2/repository

escherize15:08:28

Am I correct in thinking that reduce is the same as foldl as mentioned here: https://en.wikipedia.org/wiki/Fold_(higher-order_function)#Folds_as_structural_transformations

escherize15:08:36

I can't see why a foldr operation would ever be more useful

escherize16:08:08

(reduce func initval list) ;;foldl
(reduce func initval (reverse list')) ;;foldr

niwinz16:08:29

Foldr is usefull in languages like haskell that has not strict parameters evaluation

niwinz16:08:26

The only case where is usefull in languages like clojure, is fold a lazy-seq into an other lazy-seq

niwinz16:08:44

so foldr can return a lazy-seq and to be fully friendly with the lazy evaluation

escherize16:08:56

Hmm, how's that?

niwinz16:08:18

http://funcool.github.io/cats/latest/#_foldable a little bit of explanation and implementation of generic foldl and foldr for few of clojure data structures

escherize16:08:33

I assume that's with necissarily finite lazy seqs?

niwinz16:08:01

No, they not necesarely to be finite.

chouser16:08:48

Is there any value gained in using an immutable map (over a mutable one) when some of the "values" in the map are themselves mutable (eg. an atom)?

potetm16:08:32

Man, I can’t imagine a great reason to have a map full of atoms. That would need a good explanation.

potetm16:08:04

(as opposed to a single atom with a map)

chouser16:08:09

Seems like we do it a lot. @stuartsierra's Components essentially require it, don't they?

chouser16:08:40

I don't mean to be pointing fingers, just thinking aloud.

potetm17:08:17

Ah, so you mean a map referring to what amounts to a single instance? (like a db connection, or a connection pool, etc)

chouser17:08:15

Well, in the Components example, you often have some immutable values in the map as well as some mutable ones.

potetm17:08:23

I would think there’s still value there. You (probably) don’t want to loose your instance just because someone dissocs in the middle of a get-in. I dunno, just my initial take.

chouser17:08:01

hm, ok, I see your point.

niwinz17:08:29

You can declare mutable properties in records

niwinz17:08:41

if you just want mutable properties

niwinz17:08:51

I have used a lot the stuart sierra component model and almost never I have needed "mutable state" in the components

chouser17:08:29

niwinz: really? no database connection objects or sockets or anything?

niwinz17:08:45

Yes, database connections and sockets

chouser17:08:53

that's mutable state

niwinz17:08:37

yes, but you should not set them in a atom. Just return a new transformed record in start function

chouser17:08:40

right. I'm referring to the mutability or side-effectful nature of the thing. An atom is one example, a socket is another.

niwinz17:08:26

Yeah, the atom can not be compared directly to the socket. But, in any case, the side-effects are inevitable...

Lambda/Sierra18:08:07

@chouser Part of the motivation for 'Component' is to make working with mutable Java objects feel more like working with values. Although application code using components doesn't often care, the 'Component' library relies on it internally.

Lambda/Sierra18:08:45

Although now that I think about it a bit, it could probably work with mutable maps as well.

chouser18:08:37

stuartsierra: but beyond supporting use of mutable Java objects, the Component API requires, if a value in a component is to be updated, that it must be mutable.

chouser18:08:30

This has caused me to be skeptical of Component for a while, during which time I've been looking for alternatives.

chouser18:08:29

But I should say, since we're talking about it, that I've found nothing acceptable (to me) yet, and am using Component pretty widely at this point. So thanks, @stuartsierra, for putting something concrete out there!

Lambda/Sierra18:08:45

@chouser: You're welcome! I've struggled with the same issue but never come up with a satisfactory solution.