#clojure log - Jun 21 2015

The Joy of Clojure
Main Clojure site
Google Group
List of all logged dates

0:00 zapho53: I have a function with a let binding followed by 2 function calls which add something to a database. Whichever way round I switch them only the last one executes.

0:01 amalloy: zapho53: they are both returning a lazy sequence, which you forget to force any elements from

0:01 zapho53: Both functions have a YeSQL <! return value.

0:02 amalloy: Then why does 1 execute?

0:02 amalloy: because you return it, and whoever is above you in the call hierarchy happens to force it

0:03 zapho53: amalloy: How do I get both to execute?

0:03 amalloy: i mean there are other possible explanations and i don't know what this yesql thing is, but this is by far the most likely cause for the scenario you are describing, absent any code snippets to the contrary

0:04 zapho53: try wrapping them both in (doall ...) to prove or disprove my supposition

0:04 zapho53: amalloy: Tried that once but maybe I screwed it up. Will try again.

0:05 amalloy: if that isn't the answer you will have to link to some actual code, or find someone who knows what yesql is

0:05 pranavrc: Hi. I'm having a little trouble with the syntax for unquote-splicing inside a macro. I've pasted the details here: http://pastie.org/10251103 Can someone suggest what might be wrong?

0:06 zapho53: amalloy: doall results in this error: clojure.lang.LazySeq cannot be cast to java.lang.Number

0:07 amalloy: zapho53: then we have fixed the problem you asked about, and advanced to some other error

0:07 zapho53: amalloy: Which is weird because both functions will execute the desired result if put last in the order.

0:08 amalloy: pranavrc: ` is shorthand for writing the tedious (list 'let ...) stuff you are doing by hand. you don't want to use both in most contexts

0:09 you could either write `(let [~'time (now)] foo bar baz), possibly with some more quoting depending on what foo/bar/baz actually are, or (list `let ['time `(now)] `foo `bar `baz), possibly with less quoting that again depends on what foo/bar/baz are

0:14 pranavrc: amalloy, I can't use `foo `bar `baz there as is, because the ~@(list foo bar baz) component I've included is actually a different function call that returns a list. I just used a different function for brevity.

0:15 amalloy: okay, so it's `(let [~'time (now)] ~@(whatever))

0:16 pranavrc: amalloy, in which case I still get the illegalstateexception error for unbound unquote

0:16 amalloy: no you don't. you can't get that exception from the code i pasted, unless (whatever) by itself also throws that exception

0:17 in which case, fix whatever

0:26 pranavrc: amalloy, alright, thanks!

0:26 amalloy: pranavrc: i suspect the reason whatever throws is you are trying to unquote stuff inside it, like @(whatever ~foo)

0:27 which is not what you want. you have already unquoted the whole expression

0:27 pranavrc: amalloy, yeah, that was the problem.

2:47 Thebreaker: www.VALBOT.COM provides domain valuations. Reporting globally on Site Traffic, Pagerank, Malware, WHOIS data, SEO & even Social Media presence.

3:25 kwladyka: How clojure is developing during all this years? What can we estimate about job and projects in Clojure?

4:11 ttt_fff: how does one implement tuples in clojure?

4:11 expez: by using a vector

4:18 TEttinger: (inc expez)

4:18 lazybot: ⇒ 1

4:19 TEttinger: yep, vectors already allow whatever for types, so you have the main advantage of tuples in a statically typed language right there already. and they're a single value, so that's the other use

4:31 rs0: also destructuring

4:49 mskoud: Hi there!

5:01 kaffeeboehnchen: Good morning. :) I have this macro: https://paste.xinu.at/dabljg/clojure When I call it I get a null pointer. test-auth is working with the data I am calling the macro with if I call it on its own. What am I doing wrong?

5:03 Chousuke_: is authed-header actual clojure code?

5:03 kaffeeboehnchen: Yes.

5:03 Chousuke_: how does the macro invocation look?

5:03 kaffeeboehnchen: it is a map looking like that: {:status 123 :body "hi"}

5:04 (handle-request test-request other-fun)

5:04 Chousuke_: your macro is passing the symbol 'test-request to test-auth

5:04 kaffeeboehnchen: my goal is to call other-fun when authed-header does not have a specific status and give other-fun the same request.

5:05 ah, ok

5:05 Chousuke_: why does this need to be a macro? :/

5:05 kaffeeboehnchen: I have no clue to do it otherwise.

5:05 If there is a better way please tell me.

5:06 other-fun will not always be other-fun by the way

5:06 the function which should be called will change

5:06 Chousuke_: can't you just (if (check-status authed-header) blah (other-fun authed-header))?

5:07 amalloy: the easiest way to make this macro be a function is to change the defmacro to defn. it would be closer to working that way

5:07 Chousuke_: you can pass functions as arguments to other functions

5:07 kaffeeboehnchen: But doesn't it get evaluated the moment I pass it?

5:07 Chousuke_: evaluated?

5:08 if you pass it in a variable, why does that matter?

5:08 kaffeeboehnchen: It only should be executed if authed-header has the status 202

5:08 Chousuke_: it won't be executed.

5:08 it's just a function

5:08 kaffeeboehnchen: ok

5:09 Chousuke_: I'm still not sure if I understand your problem correctly

5:09 kaffeeboehnchen: Later I wanna call (handle-request request this-fun), (handle-request request that-fun), (handle-request request other-fun).

5:10 Chousuke_: yeah, that's just fine

5:10 kaffeeboehnchen: Ok. Thank you very much!

5:10 Chousuke_: I mean, if you do eg. (list + -), that won't actually call the + - functions

5:10 you just get a list that contains them

5:10 kaffeeboehnchen: aaaaahh

5:46 ambrosebs: what's the current stance on Java 7 support in core/contrib?

5:47 going away soon?

6:17 TEttinger: ambrosebs: I wasn't aware core/contrib was still around, tbh

6:18 ambrosebs: core+contrib

6:18 TEttinger: but unless clojure is specifically moving from 6 compat to 8 compat, I kinda wonder why they would do that

6:19 (did clojure stop supporting JDK6 and thus android?)

6:19 ambrosebs: good question

6:19 kwladyka: Can i discuss with somebody about Ring architecture? My goal is learn about architecture on this project.

6:22 first of all what determine to separate catalogs core/devel/jetty-adapter/servlet as root direcotries, not as src/* directories?

6:27 as i understand ring respository has 4 projects 1 one, why not 4 separater ring repository?

6:34 Jickelsen: I've included react-with-addons (from CDN) but (aget js/React "addons") returns nil. Any ideas?

6:49 kwladyka: ok, next step... i understand magic happens because of lein-sub library

6:55 crocket: clojure repl uses 600MB of RAM from the beginning.

6:55 How do I tame its memory usage?

7:03 kwladyka: so next... ring project use lein-sub and has :sub in profile.clj for subprojects, but this subprojects doesn't have main function or something like this. Also if i understand then run as casdace one by one, not paraller or... exatly opposite to cascade, because i am not sure how to interpratate "Should you need recursive behavior, consider Leiningen aliases or lein-cascade." and if not main functions inside... what exatly is running?

7:06 crocket, what do you mean clojure repl? "lein repl"? for me 1 136K memory

7:07 crocket: yes

7:07 lein repl

7:07 It uses 620MB of RAM inside cider repl which is essentially lein repl.

7:08 kwladyka: crocket, "lein repl" for me on windows get only 1 136k memory

7:09 maybe you interpret used memory by process in bad way if you running repl inside another application

7:09 crocket: I?

7:09 not me

7:09 clojurebot: I will never forgive that

7:10 kwladyka: mmm?

7:13 crocket: Look at http://imagebin.ca/v/25zcAKgAPHTq

7:14 lein repl ends up using 1GB

7:14 kwladyka, ^^

7:15 kwladyka: crocket, i relogin to IRC, i guess i miss something

7:19 TEttinger: kwladyka: crocket meant http://imagebin.ca/v/25zcAKgAPHTq

7:20 lein repl uses more or less RAM based on the project you're in, IIRC

7:20 since it does load the whole project to make it available, IIRC

7:23 kwladyka: my mistake, but still i have 200 MB or 250MB, I forgot :)

7:42 crocket: TEttinger, It is a very minimal leiningen project.

7:42 It only has 3 functions.

7:43 ambrosebs: how can I tell lein to never compile/test a file in my test path

7:43 TEttinger: then... just curious, how much free RAM do you have on your machine?

7:43 it's possible Java's gobbling up more than it currently needs in anticipation for later usage

7:44 crocket: TEttinger, 8GB of RAM and 13.5GB of swap.

7:44 TEttinger: is it swapping now?

7:44 crocket: no

7:44 The system currently uses 2.5GB of RAM in total.

7:45 And, swapping doesn't necessarily lead to HDD access as far as I know.

7:45 However, swapping is not desirable.

7:45 TEttinger: oh that could be why then, you have enough free that java thinks it can take a whole lot, I guess

7:45 I know modern browsers do this

7:45 crocket: It could be -Xms option.

7:46 -Xms 512M could cause this.

7:46 TEttinger: uh yes

7:46 that would make it always start with 512 MB used, do you want to know if it's used by lein?

7:47 crocket: The command lines don't specify -Xms or -Xmx.

7:47 I don't like this.

7:47 Python wouldn't consume this much.

7:49 hexchat consumes 23.5MB of RAM.

7:49 Does anyone plan to port clojure to python 3?

7:49 It wouldn't make sense for performance reasons, though.

7:49 TEttinger: huh, interesting. https://github.com/technomancy/leiningen/blob/master/bin/lein#L156-L158

7:49 crocket:

7:50 $google pixie lang

7:50 lazybot: [pixie-lang/pixie · GitHub] https://github.com/pixie-lang/pixie

7:50 TEttinger: it's very close to clojure, implemented in RPython (what PyPy uses) but not meant to call Python code yet

7:50 startup is one of its reasons to exist

7:50 kwladyka: crocket, i found solution like that about memory "You can set :jvm-opts in the user profile if you're using Leiningen 2. Otherwise set JVM_OPTS as an environment variable." Did you try that?

7:51 crocket: kwladyka, no

7:51 I didn't know about it.

7:51 TEttinger: yeah, I'd check if something else set your JVM_OPTS env var

7:52 crocket: I use leiningen 2.5.1 on openjdk 1.8.0_45.

7:52 Nothing sets JVM_OPTS in the user shell.

7:52 TEttinger: hm

7:52 JAVA_OPTS can also do it

7:53 (older java used that, lein treats it as an alias)

7:53 kwladyka: https://groups.google.com/forum/#!topic/clojure/h3M-LSlE4dw Larry Travis answer - maybe it is solution for you

7:53 crocket: I expect pixie to be different from clojure.

7:53 TEttinger: yes, no libs for one :)

7:53 crocket: No clojar

7:54 TEttinger: but it's very very close in terms of language features. it's also at an early state, (they were doing a major refactor last I checked a few months ago, to try to change how lazy seqs worked or something)

7:57 crocket: Ok, I specified :jvm-opts in ~/.lein/profiles.clj

7:57 Why did they name it pixie?

7:57 If they wanted it to be a clojure implementation on python, they would have named it accordingly.

7:58 TEttinger: I'm working on a clojure-like lisp as well, but using Perl 6's toolchain instead of PyPy. I'm encountering a rare problem in that the tools I am using to implement a new language, already have way more features than my language is going to even plan to have

7:58 it isn't directly clojure, and they planned to diverge in new features

7:58 (they have transducers in from the start, for example)

7:59 ^ last 2 lines re: pixie

7:59 crocket: I expect clojure to be faster than the perl reincarnation and pixie.

7:59 python VM is not fast enough.

7:59 TEttinger: yes. except for startup and memory usage

8:00 crocket: pixie would suit command line programs and GUI programs.

8:00 Because of startup time and memory usage.

8:00 TEttinger: java and the JVM have atrocious startup time compared to scripting language VMs. thankfully, the perl thing I'm using can produce JVM bytecode or a scripty VM's bytecode (MoarVM)

8:01 crocket: Will anyone fix clojure's slow startup time?

8:01 TEttinger: there are some ways you can mitigate it

8:01 crocket: JVM itself is not slow to launch.

8:01 TEttinger: starting with the --server JVM will always slow down launch relative to --client

8:02 but --server does way more opts as your program runs

8:02 crocket: I heard http://clojure-android.info/skummet/ aims to reduce startup time.

8:02 TEttinger: there's a mix in JDK 7 and newer, you can pass the args... let me find em

8:02 crocket: skummet

8:04 TEttinger: -server -XX:+TieredCompilation

8:04 the second arg is only available for server JVMs, and it gives it -client JVM like startup behavior

8:04 it SHOULD be the default on -server

8:05 crocket: It seems leiningen ignores ~/.lein/profiles.clj outside leiningen projects.

8:05 TEttinger: low-end machines, particularly 32-bit windows machines, don't always have -server available as an option

8:06 crocket: It seems lein repl is beyond hope.

8:07 It is greedy of RAM.

8:08 TEttinger: were you passing an -Xmx option?

8:08 crocket: yes

8:08 -Xmx512m

8:08 And, it uses 350MB.

8:09 TEttinger: well that's not disobeying the -Xmx, but it is still a fair amount...

8:09 crocket: Why does leiningen ignore ~/.lein/profiles.clj outside leiningen projects?

8:10 TEttinger: I don't know if it does, actually -- I think the profile may affect your project when it runs, not the lein program itself

8:10 but I have no idea

8:11 crocket: I mean lein repl

8:11 Why does 'lein repl' ignore ~/.lein/profiles.clj outside leiningen projects?

8:15 TEttinger: oh!

8:15 The :base profile provides dependencies necessary for basic repl functionality, adds dev-resources to the :resources-path, and sets defaults for :jvm-opts, :checkout-deps-share and :test-selectors. It is part of Leiningen itself; you shouldn't need to change it.

8:17 crocket: TEttinger, What is the clojure-like language that targets perl 6?

8:17 Does it compile to perl 6?

8:18 TEttinger: uhhh I'm making it and I don't know perl 6, don't expect much yet :)

8:18 https://github.com/technomancy/leiningen/blob/9c5192e6520fb96aa625313a468e0143001f54ca/leiningen-core/src/leiningen/core/project.clj#L467-L470

8:18 that link is the default set of JVM opts that :base adds

8:18 crocket: It seems Rakudo Perl targets MoarVM and JVM.

8:18 TEttinger: yes

8:18 that's what I will too

8:18 crocket: Whut

8:19 TEttinger, How are you desining your clojure-like language?

8:19 What does it target?

8:19 TEttinger: I'm writing it with NQP, which is Not Quite Perl, a subset of Perl 6 meant for making compilers

8:19 (perl 6 is really really big in terms of feature scope)

8:20 (NQP is a smaller subset that they can bootstrap)

8:21 anything that uses NQP to make a compiler outputs a "QAST", which is effectively the same as a clojure ast in my case after it's been fully macroexpanded (no compile time logic)

8:21 JVM and Moar backends take a QAST and compile it to a native jar or exe, respectively, I think

8:21 crocket: Is there any clojure implementation suitable for command line programs?

8:21 or any lisp

8:22 TEttinger: I'd say pixie is about as close to clojure and command line as you'd get

8:22 crocket: pixie dust

8:22 TEttinger: other things get more scheme-like or common lisp like

8:23 SBCL has worse compile times than clojure, from what I hear, but produces very good optimizations

8:23 (not sure about repl in there)

8:23 crocket: "Pixie implements its own virtual machine. It does not run on the JVM, CLR or Python VM."

8:23 TEttinger: yep

8:23 crocket: And, it's written in python.

8:23 TEttinger: PyPy's RPython is a toolchain for making VMs

8:24 well, the bootstrapper is in RPython and even that isn't all of Python

8:24 crocket: Is scheme decent for command line programs?

8:24 wasamasa: yes

8:24 crocket: What about common lisp?

8:24 TEttinger: there are many schemes though

8:24 wasamasa: common lisp sucks for that purpose

8:24 not a single open-source implementation has tree shaking

8:25 TEttinger: racket is a good bridge between Clojure features and Scheme-ness

8:25 wasamasa: and therefore cannot produce binaries comparable with what you'll otherwise find there

8:25 crocket: ???

8:25 lazybot: crocket: Yes, 100% for sure.

8:25 TEttinger: there's actually a racket lib that adds clojure data structures, immutable and all, to racket

8:25 crocket: I don't know tree shaking.

8:25 TEttinger: Racket is a scheme

8:25 crocket: Is Racket a functional programming language?

8:25 wasamasa: nope

8:25 TEttinger: ?

8:26 crocket: Is there a functional lisp dialect suitable for command line?

8:26 TEttinger: racket has immutable and mutable data structures like clojure

8:26 wasamasa: it's a good deal closer than CL though

8:26 crocket: stop treating "functional" as a binary value

8:27 crocket: makes about as much sense as doing the same for OO

8:28 crocket: javascript sucks.

8:28 TEttinger: racket doesn't support the same type of concurrency stuff as clojure. I don't think any other lisps do as well as clojure in that arena

8:28 crocket: pixie is close?

8:28 pixie has STM and CSP.

8:28 TEttinger: do you mean CPS?

8:29 wasamasa: crocket: I also suggest you to just start writing code instead of spending all day asking #clojure about theoretical things

8:29 TEttinger: I like talking though!

8:29 it means my brain hurts less from perl stuff!

8:29 expez: I deployed a version that I don't want to promote to a proper release to clojars, when I try to deploy agai I get ReasonPhrase: Forbidden. What gives?

8:30 wasamasa: crocket: you may learn valuable things along the way such as that there is no perfect programming language

8:30 crocket: or that one programming language is better suited for a certain task than another

8:30 TEttinger: clojure is very very good for server apps

8:30 wasamasa: crocket: or that people writing code usually learn other languages as well

8:31 crocket: ClojureScript on node.js could be made decent on command line.

8:35 TEttinger, Do you have other recommendations for command line than pixie?

8:35 pixie doesn't even have a tutorial yet.

8:37 TEttinger: try lots of lisps. racket has a heavy focus on being useful for whatever people want to adapt it for, since it's primary unique feature is the ability to make new language modes that are still valid racket (one has algol syntax)

8:37 racket also has a better documentation generator than, uh, everything

8:38 (it's a tool called Scribble and it really produces very good docs)

8:38 crocket: Whut

8:39 Does clojure target python vm?

8:39 TEttinger: not that I know of, it potentially could

8:39 better would be LLVM, like many other languages are starting to try

8:41 crocket: https://github.com/halgari/clojure-py/ not useable

8:41 only 7 commits

8:41 TEttinger: as far as I can tell, LLVM has a number of advantages that explain why Apple is investing so heavily in it, and one is the quality of debugging and compilation speed that they get with Clang, the C/C++ compiler targeting LLVM, relative to GCC

8:41 crocket: LLVM sounds complex.

8:41 TEttinger: it is. it does have a lot of stuff under its banner

8:42 wasamasa: crocket: will you promise me to go quiet if I hand you a lispy language with a tutorial that's capable of producing executables and starting up quickly?

8:42 TEttinger: hehe

8:43 wasamasa: not to mention an alive community and sufficient amount of libraries

8:44 crocket: That sounds magical

8:44 wasamasa: it's not if you relax your criteria a bit

8:44 http://call-cc.org/

8:44 crocket: Actually, I was overwhelmed by lisp dialects....

8:44 Racket, chicken scheme, et al...

8:44 wasamasa: I'm using it for writing my CLI utilities and some simplistic web applications

8:45 crocket: I surmise chicken scheme is a decent language.

8:45 wasamasa: it's no clojure, but eh, I'm fine with scheme

8:47 crocket: I'd be happier if there is a clojure implementation that starts up fast because that means one less language to learn.

8:47 wasamasa: lol

8:48 crocket: I could probably try ClojureScript on node.js

8:48 wasamasa: just give up on it, as a good developer learning languages is a necessity

8:48 well, clojurescript's tooling sucks

8:48 crocket: Does it have leiningen?

8:48 wasamasa: you'll have to start with a clojure project first, then add clojurescript as dependency

8:48 then write some lines to make leiningen compile javascript

8:49 crocket: wasamasa, It seems chicken scheme implements R5RS. Does R6RS improve on R5RS in any aspect?

8:49 wasamasa: crocket: R6RS is very different from R5RS

8:50 crocket: R7RS is an attempt to actually improve R5RS and splitting the language into a small and large version

8:50 crocket: and chicken supports a good amount of the small version of R7RS

8:52 crocket: It seems committee has dominated scheme.

8:52 * wasamasa wonders whether crocket is just another incarnation of gavino

8:53 crocket: I have a selection disorder.

8:57 wasamasa, Does chicken scheme compile to native binaries directly?

8:57 kwladyka: wasamasa, did you use lein-sub?

8:57 * wasamasa smacks crocket with a big cup of TIAS

8:57 wasamasa: kwladyka: nope

8:57 Bahman: wasamasa: Count me in :-D

8:58 wasamasa: Bahman: and I thought I was just seeing things

8:58 kwladyka: wasamasa, ok. I am just looking somebody who can explain me https://github.com/ring-clojure/ring architecture :)

8:59 wasamasa: kwladyka: not sure how a leiningen plugin comes into play there

8:59 Bahman: crocket: One of the strengths of Chicken (and Racket) are native binaries.

8:59 wasamasa: Bahman: didn't racket switch to having a VM?

8:59 Bahman: wasamasa: Yes...but the binary contains the slimmed down VM for easy redistribution.

8:59 Pretty neat.

9:00 kwladyka: wasamasa, do you have any idea why author of code choose to have all this projects inside one repository then separate them?

9:00 wasamasa: well, ok

9:00 kwladyka: I suggest asking them

9:00 kwladyka: ;)

9:01 it can be a solution :)

9:01 and maybe the esiest in this case

10:02 crocket: Is it ok to write a GUI program in clojure with a JavaFX binding?

11:19 whodidthis: https://www.refheap.com/104291 any way i could make core.match work in tests? 😿

11:25 crocket: Will clojure be fixed with regard to nil?

11:26 mmeix: What should be fixed?

11:26 crocket: nil

11:26 Nil causes errors

11:27 mmeix: example?

11:27 ,(doc fnil)

11:27 crocket: (if ({:a nil :b 1} :a) "ok" "no")

11:27 clojurebot: "([f x] [f x y] [f x y z]); Takes a function f, and returns a function that calls f, replacing a nil first argument to f with the supplied value x. Higher arity versions can replace arguments in the second and third positions (y, z). Note that the function f can take any number of arguments, not just the one(s) being nil-patched."

11:27 crocket: ,(if ({:a nil :b 1} :a) "ok" "no")

11:27 clojurebot: "no"

11:28 crocket: It leads to logical bugs.

11:28 ,(if (contains? {:a nil :b 1} :a) "ok" "no")

11:28 clojurebot: "ok"

11:29 crocket: Since nil is everywhere, it is difficult to find the origin of nil.

11:29 whodidthis: maybe core.typed will help you out

11:30 crocket: nil should have been an interop feature.

11:31 mmeix: ,(if ({:a nil :b 1} :a) "ok" "no")

11:31 clojurebot: "no"

11:31 mmeix: is perfectly ok, because nil is falsey

11:32 "Both nil and false are treated as "false" and everything else is treated as true."

11:32 http://blog.jayfields.com/2011/02/clojure-truthy-and-falsey.html

11:32 crocket: Somehow, it leads to bugs.

11:32 nil leaks into collections.

11:32 conditionals return false because nil leaked into collections somehow in a large codebase.

11:33 mmeix: I guess, nil will not declared truey ...

11:34 Bronsa: crocket: no, it will never be "fixed". it's not considered a bug or misfeature

11:34 mmeix: maybe this helps:

11:34 http://blog.jayfields.com/2011/01/clojure-fnil.html

11:34 crocket: nil shouldn't have been part of the core in the first place.

11:34 Bronsa: that's your opinion

11:34 crocket: Rich Hickey was forced to use nil due to JVM.

11:35 Bronsa: do you have any evidence to back that claim or is it just you assuming things?

11:35 crocket: Nil is a mistake in programming languages.

11:35 Nil, Null, ...

11:35 Bronsa: cool. you seem to have made up your mind. have fun trying to convince the core team I guess

11:36 crocket: mmeix, I think fnil is a band aid at best.

11:37 mmeix: hm ...

11:38 I'm a beginner, but the concept of only nil and false being falsey seemed very plausible to me

11:38 instead of say 0 being false, for example

11:38 etc.

11:38 crocket: mmeix, My point is that I feel much better without nil in the core.

11:39 Nil is better served as a java interop feature.

11:39 mmeix: this is not going to happen, it would break nearly everything

11:39 crocket: I know

11:39 mmeix: AFAIK

11:40 what is wrong with your example (if ({:a nil :b 1} :a) "ok" "no")?

11:40 don't see the point

11:40 crocket: If a programmer assumes a map doesn't have nil, it is a problem.

11:42 mmeix: Something other: trying "boot" for he first time, and doing some silly error somewhere - could someone have a quick look at: https://www.refheap.com/104324

11:44 ,(contains? {:a nil :b 1} :a)

11:44 clojurebot: true

11:44 mmeix: if that matters

11:47 what should (first {}) return? false?

11:47 ,(first {})

11:47 clojurebot: nil

11:59 crocket: Why does clojure not have an option type?

12:23 hellofunk: is the idea behind an option type to simply differentiate between "no value is there" vs "a value is there, but the value is nothing" ?

12:30 noidi: crocket, http://clojure.github.io/core.typed/#clojure.core.typed/Option

12:32 crocket: Thanks

12:32 mmeix: ad hoc: is core.typed preferable to prismatic/schema ?

12:32 crocket: I have my eyes on pixie which is similar to clojure and loads fast.

12:33 pixie would be great for embedded devices and command line programs.

12:34 whodidthis: maybe you can start a core.typed for pixie

12:34 justin_smith: mmeix: schema is about runtime assertions, typed is about proving things at compile time

12:35 mmeix: ah, ok ... thanks

12:39 clojer: I'm finding the more I work with Clojure the more I don't want to work with anything else. Can't decide whether that's a good or a bad thing :)

12:42 S-expressions just make it so easy to extract parts of a function and test in the repl by throwing some values at them.

12:48 hellofunk: clojer: welcome to lisp!

12:49 * wasamasa wonders how to name the 15 minute talk he's supposed to hold at college

12:49 wasamasa: they want to know from me what I've learned at work

12:49 and it's been mostly clojure and clojurescript

12:50 Jickelsen: Asked this before but it was probably at a bad time of day :) I've included react-with-addons (from CDN) but (aget js/React "addons") returns nil. Any ideas?

13:12 kwladyka: What are you using to database migrations?

13:15 sdegutis: Are there any decent OCR libraries for Clojure?

13:25 clojer: Why does seq destructuring of a map change the original? For example:

13:25 (let [m { 365 [{:a 1 :b 2} {:a 4 :b 6}] 366 [{:a 11 :b 22} {:a 44 :b 66}]}] (for [[id [mps] :as orig] m] orig))

13:25 Produces: ([365 [{:b 2, :a 1} {:b 6, :a 4}]] [366 [{:b 2, :a 1} {:b 6, :a 4}]])

13:26 The original map has not been retained as a map.

13:26 justin_smith: clojer: a hash-map is made of entry objects

13:26 TEttinger: because for isn't changing the original?

13:26 for returns a new seq

13:26 justin_smith: for cannot return a hash-map

13:27 you can make a hash-map out of the entries there though

13:27 TEttinger: ,(let [m { 365 [{:a 1 :b 2} {:a 4 :b 6}] 366 [{:a 11 :b 22} {:a 44 :b 66}]}] (into {} (for [[id [mps] :as orig] m] orig)))

13:27 clojurebot: {365 [{:a 1, :b 2} {:a 4, :b 6}], 366 [{:a 11, :b 22} {:a 44, :b 66}]}

13:28 clojer: I naively thought :as orig did exactly that, ie. saved the original, not transformed it.

13:29 whodidthis: orig there is a single key value pair

13:30 justin_smith: clojer: :as is a convenience for capturing bindings, but there is no binding in for that will capture the entirety of the original collection

15:11 whodidthis: how do i make a string from a list of strings in emacs lisp

15:11 Bronsa: whodidthis: what does this have to do with clojure?

15:13 whodidthis: ok, whats kind of like (apply str '("abc" "def")) but in emacs lisp

15:14 TimMc: haha

15:14 whodidthis: most of us not originated from the great land of lisp :(

15:15 s/most/some

15:18 wasamasa: (mapconcat #'identity '("foo" "bar") "")

15:18 next time, ask on #emacs

15:20 you can alternatively do it like you'd do in any other lisp, but I bet there's some stupid reason for not doing so, like it's version of apply and funcall being braindead

15:20 yup: "If a subr takes more than 8 arguments without using MANY or UNEVALLED, we need to extend this function to support it. Until this is done, there is no way to call the function."

15:27 TimMc: ...emacs lisp can't apply when the fn doesn't specifically support it?

15:31 wasamasa: that's in the sources of funcall

15:31 so, I dunno how to interpret this, maybe it's a limitation at the C level

15:32 experimentation at elisp level doesn't suggest there's anything wrong

15:36 whodidthis: apparently there was a new function called string-join, i was a bit dum for trying to find something apply-like in elisp

15:42 wasamasa: it's using the same thing I suggested

15:42 and is relatively recent

16:34 kwladyka: Is any common rules for returning errors in Clojure from functions? For example validation error like "email is to valid".

16:46 Why you will choose Pedestal instead of Ring?

16:48 tcrayford____: kwladyka: for the former question: typically I'd use a value like a map or something in that case, exceptions in others

16:49 kwladyka: tcrayford____, yes.... i can't get used to i don't need some class for that...

16:50 Do you have any experience Validateur vs Bouncer?

16:50 tcrayford____: nope. I use mississippi and it's worked fine for me

18:01 zakwilson: I'm looking for an IMAP client library. All I've found so far is clojure-mail, a very gmail-specific wrapper around JavaMail. Is there something more general I should look at, or should I just use a Java library?

18:03 bbloom: zakwilson: in general, you should prefer java libraries over clojure wrappers of java libraries.... unless the clojure wrapper is particularly good

18:03 clojure is designed to make it easy to call jvm code w/o a wrapper. so the wrapper needs to provide some substantial benefit to justify itself

18:05 and "saves you from typing a dot character" is not substantial benefit

18:07 zakwilson: No, but converting from Java's representation of an email message to a Clojure map and dealing with what look to be a few thorny issues with JavaMail like clojure-mail does might be.

18:12 bbloom: zakwilson: a quick look at the library suggests to me it's probably not worth wrapping

18:13 or at least not worth wrapping in a general way: write the adaptor functions you need, reference clojure-mail if you need to for how to do some things

18:13 cut out all the stuff you don't need/want

18:14 or fork it and make the changes you need to be less gmail-specific

18:16 zakwilson: bbloom: I was leaning toward forking it, as that doesn't look terribly hard. I was hoping for there to be a Right Thing I could use though, and it doesn't look like there is.

18:18 bbloom: zakwilson: i was telling you what (many in) the community will tell you is "the right thing": just call the jvm libs & write functions to make it nicer as you need them

18:18 the extra indirection only adds bulk and complexity

18:21 jonathanj: is there a better way of expressing: (into {} (for [[k v]] (some-func {:x k} v))) ?

18:23 bbloom: jonathanj: not sure what you're trying to express, since your `for is malformed

18:23 jonathanj: it is?

18:24 bbloom: ,(for [[k v]] anything)

18:24 clojurebot: #error {\n :cause "for requires an even number of forms in binding vector in sandbox:"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.IllegalArgumentException: for requires an even number of forms in binding vector in sandbox:, compiling:(NO_SOURCE_FILE:0:0)"\n :at [clojure.lang.Compiler macroexpand1 "Compiler.java" 6644]}\n {:type java.lang.IllegalArgumentExce...

18:25 jonathanj: (for [[k v] some-map] ...) then

18:25 bbloom: jonathanj: you need an expression for [k v] to iterate over

18:25 so you're trying to apply a function to each key in a map and then get a new map with the same values?

18:26 jonathanj: uh, i don't think that's what that code does

18:26 i want to apply a function to each value in a map, with access to the key, and have it result in a new map

18:27 bbloom: (reduce (fn [m [k v]] (assoc m k (f k v))) {} m)

18:29 or just (into {} (map f m))

18:34 jonathanj: bbloom: yeah, i guess into map makes more sense than into for, thank you

18:36 whomp: how can i get a list of all the values of a hashmap? like the keys fn, but for values instead

18:37 oh... vals... seems reasonable

19:17 jonathanj: is there a less repetitive way of writing: (cond (map? value) ... (vector? value) ...)?

19:18 bbloom: jonathanj: what repetition are you attempting to eliminate?

19:18 justin_smith: jonathanj: for one thing, a multimethod can replace a cond over types

19:19 jonathanj: bbloom: repeating `value`

19:20 justin_smith: true, but it's quite a small task

19:22 bbloom: jonathanj: you can 1) just deal w/ it, as it's not the problematic kind of repetition (spreading knowledge to multiple places) or 2) choose a smaller variable name or 3) probably can use condp

19:22 (doc condp)

19:22 clojurebot: "([pred expr & clauses]); Takes a binary predicate, an expression, and a set of clauses. Each clause can take the form of either: test-expr result-expr test-expr :>> result-fn Note :>> is an ordinary keyword. For each clause, (pred test-expr expr) is evaluated. If it returns logical true, the clause is a match. If a binary clause matches, the result-expr is returned, if a ternary clause matches, its result-fn, which must be a unary fu

19:23 bacon1989: bbloom: it was something I was going to suggest, but I think that would just lengthen his code

19:23 IPersistentMap doesn't seem shorter to me ;)

19:26 bbloom: ,(let [value "foo"] (condp (fn [f _] (f value)) nil keyword? 1 symbol? 2 string? 3 number? 4))

19:26 clojurebot: 3

19:27 bbloom: you can write a macro for that, or a custom macro built on cond

19:27 or, really, just don't worry about that superficial repetition

19:29 ,(defmacro condv [v & clauses] `(let [v# ~v] (condp (fn [f# _#] (f# v#)) nil ~@clauses)))

19:29 clojurebot: #'sandbox/condv

19:29 bbloom: ,(condv "foo" keyword? 1 symbol? 2 string? 3 number? 4)

19:29 clojurebot: 3

19:29 bbloom: ,(condv 567 keyword? 1 symbol? 2 string? 3 number? 4)

19:29 clojurebot: 4

19:29 bbloom: ,(condv 'there-you-go keyword? 1 symbol? 2 string? 3 number? 4)

19:29 clojurebot: 2

19:30 jonathanj: ,(condp #(%1 %2) {} map? :map :else :unknown)

19:30 clojurebot: :map

19:30 bbloom: er duh, yeah, that works better than mine closing over value

19:30 go with that

19:30 jonathanj: is there another way of writing #(%1 %2)?

19:31 bbloom: no

19:31 amalloy: infinitely many ways, but none of them very good

19:31 bbloom: yeah that

19:32 ,(defn call [f & args] (apply f args))

19:32 clojurebot: #'sandbox/call

19:32 bbloom: ,(condp call {} map? :map :else :unknown)

19:32 clojurebot: :map

19:33 jonathanj: (comp eval list) is what i came up with

19:33 but okay, i'll just use the macro

19:33 justin_smith: eval for that is like using a chainsaw to do your nails

19:35 amalloy: (inc justin_smith)

19:35 lazybot pls

19:35 clojurebot: Cool story bro.

19:35 jonathanj: i generally assume that using anything like "eval" or "exec" in any language is like that :P

20:05 bacon1989: will there every come a day where clojure is written entirely in C, and has an FFI that works with C libraries fairly well

20:06 not that i'm asking for it, I think it would be cool

20:06 I would just love to see commandline tools written in clojure

20:07 skummet definitely helps, but it's a crutch to the main problem

20:07 bbloom: bacon1989: https://github.com/pixie-lang/pixie

20:08 bacon1989: oh yeah, I think that's awesome

20:09 but that's in 'pre-alpha'

20:09 in time though

20:11 i'm liking the direction of pixie actually

20:11 maybe I just need to be patient

20:12 'clojure inspired lisp'

22:19 jjttjj1: is there a way built into incanter to get a dataset from a sequence of maps keyed by the colnames?

22:21 found it, to-dataset works

23:18 keramida: ma

Logging service provided by n01se.net