Fork me on GitHub
#clojure
<
2016-10-31
>
seancorfield00:10:41

I guess I’m not really sure what your imagined library would do for you that’s worthwhile…?

abdullahibra08:10:32

i have got an error: java.lang.IllegalArgumentException: Parameter declaration "->" should be a vector, compiling:(core.clj:1:1) Exception in thread "main" java.lang.IllegalArgumentException: Parameter declaration "->" should be a vector, compiling:(core.clj:1:1)

abdullahibra08:10:51

and nothing helpful to debug this error, which line for example

abdullahibra08:10:02

what this error refer?

iku00088808:10:14

sounds like an error when you make a malformed defn

iku00088808:10:06

e.g. (defn function dfa) would throw such message

abdullahibra08:10:57

is there a way to get which line?

iku00088808:10:22

AFIK that has been pretty difficult...

iku00088808:10:33

If it is a call to a macro, macro-expand might help?

iku00088808:10:01

(Obviously making an assumption here...)

agile_geek08:10:14

@abdullahibra you should have something that indicates the line in your full stack trace but from the message I would search the namespace for uses of the thread first macro -> and see if you have naything that looks like this:

(defn fn-defn 
  -> ......)
Which should be:
(defn fn-defn [args]
  (-> ....))

iku00088808:10:17

So there is nothing that looks like @agile_geek 's suggestion in your core.clj?

iku00088808:10:21

Or what ever file that you are trying to evaluate?

iku00088808:10:32

Most likely a malformed defn

abdullahibra08:10:58

(defn foo->foo-bar [] ) isn't write name?

abdullahibra08:10:08

foo->foo-bar ?

agile_geek09:10:45

provided you have the vector for args, which you do in that example

agile_geek09:10:17

As you can see in ClojureBot snippet above that defn evals fine

agile_geek09:10:36

Would fail if there were spaces before the ->

abdullahibra09:10:42

agile_geek got it

abdullahibra09:10:28

i was defining: (def x (-> h :hello :world)) as (defn x (-> h :hello :world)

abdullahibra09:10:50

most likely typo error

agile_geek09:10:54

@abdullahibra that would be it. Glad you found it.

blkt09:10:48

has anyone of you tried (with success) uncomplicate.neanderthal on Ubuntu (specifically 14.04)? I'm having troubles with libatlas I can't get through

matan15:10:39

hi guys, is kibit very popular around here? https://github.com/jonase/kibit

bostonaholic15:10:08

I use it on occasion

matan15:10:14

i am curious why wouldn't it exapnd macros rather than be fooled by them?

bostonaholic15:10:26

but more so when I was newer to clojure

matan15:10:37

this is more of an interest about how compilation works (e.g. lein compile)

matan15:10:33

i wonder whether one can't somehow expand macros by some way of invoking the compiler, as clearly it is the compiler's know-how

matan15:10:45

well answered my own question, I think expanding macros is just a macroexpand away

matan15:10:16

@bostonaholic thanks for the feedback, I might give it a try 🙂

kingoftheknoll16:10:06

What is the fastest/idiomatic way to return true for the first value of set A in set B? I know I can do a set intersection but that’s O(length set A). Loop or reduce maybe?

jjfine16:10:40

my guess would be (first (filter ...

keymone16:10:13

intersection seems to be lazy (defined via reduce), so doing (first (intersection a b)) is O(len_A) is only in worst case

jjfine16:10:35

nm, you wanted to return true, so maybe just (some #(contains? set-a %) set-b)

jjfine16:10:30

ah, yeah nice that intersection is lazy.

hiredman16:10:13

reduce is not lazy

keymone16:10:34

sure it can’t be lazy what am i thinking

hiredman16:10:16

the only thing lazy in the clojure language is lazy seqs, clojure.set operates on sets(it doesn't throw errors if you don't pass sets, but you will get surprising undefined behavior if you do) -> clojure.set is not lazy

danielstockton16:10:36

anyone know when euroclojure vids will be online?

josh.freckleton17:10:05

I had a general question about organizing functional projects, so I posted it on reddit and would be curious for some discussion/resources if anyone has any cool ideas they'd like to share! https://www.reddit.com/r/Clojure/comments/5adkib/best_practices_for_organizing_project_directories/

andrewhr17:10:44

@josh.freckleton I tend to follow the “module” guideline. But I personally don’t like to split things like logic.clj and just use the comments.cljs namespace directly. Then I nest inside it implementation details when necessary

roberto17:10:10

I think the most important thing for having an “organized file structure” is consistency and everyone in a team agreeing to abide by it.

josh.freckleton17:10:51

@roberto agreed. and assuming a green-field project and you get to choose the format, how do you organize?

roberto17:10:25

I prefer to organize by “module”, as you called it.

josh.freckleton17:10:33

@andrewhr that makes sense, i'd probably do the same. have you scaled up any projects like that? I'm curious if that scales, or if the choices shift when a project grows.

dominicm17:10:56

https://8thlight.com/blog/uncle-bob/2012/08/13/the-clean-architecture.html I was just reading this which might give a different insight, although indirectly. I think it's good.

andrewhr18:10:52

@josh.freckleton just a few "domain" modules, micro-service-ish

roberto18:10:27

I think that article addresses the “logical organization” while @josh.freckleton question is more about the “file organization"

roberto18:10:48

it can get confusing when both are used interchangebly

josh.freckleton18:10:59

you know, I've seen that article a few times but never commited to reading it. I will now.

andrewhr18:10:05

an experiment I ran, on the vein of clean architecture, was also creating a “module” called rt for runtime concerns. Components like SQS consumers and thread-polls

roberto18:10:19

because you can have a “hexagonal architecture” and still organize the files by “type"

andrewhr18:10:29

so domain modules become more logic centered (though not fully “pure” per se)

dominicm18:10:11

@Roberto I think they could be used to drive one another. Uncertain though. But I could see my business logic going under a prefix, use cases in another.

josh.freckleton18:10:04

What about MVC? That is an "implementation"-based structure, and I find it starts to bug me when I'm hunting down "related" files across an increasingly complex file structure. does anyone talk about that problem, and mitigating it with the MVC "pieces" living in a module, instead of in an "implementation" grouping? (or something better)

dominicm18:10:59

I just search by filename.

dominicm18:10:15

@roberto I think I was encouraging an implementation detail styled layout, where there's less duplication of entities due to the structure that's created by the clean architecture.

josh.freckleton18:10:24

that makes sense, but fails when I inherit code, or haven't worked on it for a while. it's hard to search for files I've never seen/forgotten about

roberto18:10:07

why would there be duplication of entities in a “module” layout?

dominicm18:10:10

@josh.freckleton maybe I'm misunderstanding the complaint. Related code by entity?

josh.freckleton18:10:41

@dominicm I don't think I have a complaint... just curious how these things scale. For ex: I'm working on a side project right now that's split out largely by implementation 1st, module 2nd, and it's hard to know where all the code lives that is all related "semantically"

dominicm18:10:43

@roberto I think we've misunderstood each other. I'm talking about db/too.clj threads/too.clj

josh.freckleton18:10:18

> db/too.clj threads/too.clj this is what you'd advocate then? (in general probably, since it's not "one-size-fits-all")

dominicm18:10:21

@josh.freckleton when I search by file, I can ignore the subdirectory. So I can search by the 2nd level only, if they match in the semantic way I think you're describing. Though this only works in the MVC style you originally described.

dominicm18:10:50

I've found that layout leads to 20 definitions of what a user is.

josh.freckleton18:10:24

> I've found that layout leads to 20 definitions of what a user is. this sounds like an important insight to your view, but I don't get what you mean...

josh.freckleton18:10:27

could you explain?

dominicm18:10:41

@josh.freckleton the user that threads expects, is subtly different to that of database, because they're coming from different places. This might be being caused by some other effect (slow enrichment, poorly defined contracts)

dominicm18:10:09

Mobile is a hard way to discuss this sort of thing in length.

dominicm18:10:59

I think that the clean architecture essentially gives you a better 1st level to jump off. This means the 2nd level doesn't have to duplicate the entity name so much. This, to me, is a sign of clearer boundaries between functions, and therefore decomposing of your logic.

eggsyntax19:10:40

I'm getting an error that I'm finding a bit baffling:

user> (require '[clojure.repl :as r])
nil
user> (r/pst (Exception.) 10)
clojure.lang.ArityException: Wrong number of args (2) passed to: repl/pretty-pst
Calling r/pst with either of the other arities it supports works fine. Looking at the Clojure source code, it unambiguously supports an arity of two (namely a Throwable and an integer for how many levels deep to print). And...what on earth is this repl/pretty-pst thing? "pretty-pst" appears literally nowhere in the clojure source code. I don't get it.

eggsyntax19:10:30

Anyone else encountered this before, or have a guess as to what might be going wrong?

bostonaholic19:10:34

what version of clojure @eggsyntax

bostonaholic19:10:02

{:major 1, :minor 9, :incremental 0, :qualifier “alpha13”} works for me

eggsyntax19:10:33

1.9-alpha12 -- but I checked back to 1.8, and it ostensibly supported that arity both then and now.

eggsyntax19:10:16

Haven't tested to see if I still get the error under 1.8, but that'll be one of my next steps.

eggsyntax19:10:53

@bostonaholic when you say "works for you", you mean you can call (r/pst (Exception.) 10) without getting that error?

bostonaholic19:10:19

works for me on a 1.9.0-alpha12, I’m running it under lein repl

eggsyntax19:10:13

Ah, you don't say... very interesting, thanks. That shifts my priorities for investigation for sure.

Alex Miller (Clojure team)20:10:31

@eggsyntax pretty-pst is not part of Clojure

Alex Miller (Clojure team)20:10:02

I think that’s maybe an external pst printer?

eggsyntax20:10:23

It doesn't appear in our codebase either -- but it's definitely an issue with something in our codebase, maybe a lib that tries to make REPL stuff nicer.

Alex Miller (Clojure team)20:10:37

I’m guessing you have that installed via lein user.clj or boot profile or something

eggsyntax20:10:17

That seems plausible 🙂. Don't think we use it directly (although I could be misremembering), but maybe we use something that in turn uses pretty.

Alex Miller (Clojure team)20:10:29

it’s included in ultra

eggsyntax20:10:37

Bingo. timbre has a dependency on io.aviso/pretty, which replaces repl/pst via (reset-var! #'repl/pst pretty-pst), but doesn't support all the same arities. I'll file an issue w/ pretty & ask them, if they're going to override common clojure fns, to at least support the full set of arities 😛

eggsyntax20:10:33

Thanks! But props mainly to @alexmiller, who figured out the specific library that was causing the problem.

tom22:10:24

Does anyone know if http kit does HTTP pipelining?

iku00088823:10:18

In the context of reducers, what is the difference of 'reducible' vs 'foldable' ?