Fork me on GitHub
#clojure
<
2017-04-25
>
qqq00:04:54

mine is type checked also

qqq00:04:03

the existing libraries I've played with aren't type checked

qqq00:04:13

and I find it hard to use monads without type checking to catch my errors

lincpa00:04:40

@qqq Clojure is more like Super FoxPro, not FP for me. Main advantages of clojure: data manipulation is simple and smooth. is Foxpro (or other db) needs to do type checking? 🙂

lincpa00:04:38

UNIX TextFlow using the pipe to combine command, Clojure DataFlow using -> and higher-order func to combine func.

qqq00:04:01

@lincpa : I don't get the analogy to FoxPro. I never used FoxPro.

lincpa00:04:24

separate logical flow and data flow like industrial pipeline

lincpa00:04:48

I'm Foxpro User in 1993-2010, use clojure from 2010 to now. Occasionally using C#, VB

qqq00:04:27

What is the difference between logical flow and data flow?

lincpa00:04:53

Foxpro and clojure have in common, is the data collection operation priorities, As with all DB's, separate data and code, Like separation of machines and raw materials in the industrial pipeline.

lincpa00:04:00

data is raw materials, code is machines. dataflow is river, codeflow(logicalflow) is the river bank

qqq00:04:30

I don't understand analogies. This is not helpful to me.

lincpa00:04:30

Simply put, try using ->>

lincpa00:04:35

The more, the better

lincpa01:04:00

In my clojure project (40k+lines), 90% functions is threading micro blocks.

arun.parthiban01:04:48

Does anyone have cider working with Orgmode/babel ?

lincpa01:04:58

i'm using notepad++

lincpa03:04:54

by the way, In the industrial pipeline, machine is pure function.

lincpa03:04:24

clojure like Super Foxpro, just like Datomic is a clojure-philosophy-based database

lincpa04:04:28

SQL is pure function

lincpa04:04:49

Clojure is a DB-mode-based FP language. It is much simpler and more practical than haskell.

lmergen06:04:45

A db-mode-based FP language doesn't make sense to me ?

lmergen06:04:19

I always thought Clojure was a LISP... 🙂

madvas06:04:39

Guys, is there a core function to do this:

(do-something [1 2 3] [4 5 6])
=> ([1 4] [2 5] [3 6])

tolitius06:04:00

@madvas

(into [] (zipmap [1 2 3] [4 5 6]))
should do it

madvas06:04:00

ah nice, thanks @tolitius

clojureman06:04:50

(map vector [1 2 3] [4 5 6])

mbjarland06:04:26

anybody know if clojure.spec has a way to compose specs for strings? i.e. if I have some formatting string with repeating patterns, say [1]foo[14]bar, it would be nice to use the normal spec composition instead of regex parsing to build up the spec for the full thing

mbjarland07:04:46

@lincpa much appreciated and I will add (<< to my list of tricks...though now that I see the answer I suspect I was less than crystal clear in my question : ) So I have a formatting string which verbatim says things like [L]sometext[R]someothertext etc, i.e. with brackets and all. I would like some way of defining a spec that says:

(s/def ::bracket-expr <some string operation here>)
(s/def ::between-bracket-expr <some string operation here>)
(s/def ::entire-expr (s/cat :expr (s/* (s/alt :bracket ::bracket-expr :between ::between-bracket-expr))))
without using nasty regex group repetition to express the fact that I have repeating groups within the string.

mbjarland07:04:58

i.e. define specs for parts of the string and then handle the repetition part in the spec realm

mbjarland07:04:39

seems somehow like missing the point if you have to write a 100 char regex in the middle of all this beautiful spec code

mbjarland07:04:54

I suspect this kind of string destructuring via spec is not possible but I was hoping someone would tell me otherwise

lincpa07:04:51

spec is too unreadable 🙁

mbjarland07:04:35

: ) well I'm just starting out, but it seems to me (like clojure itself) that the velocity at which it goes from unreadable to natural is quite surprising

mbjarland07:04:02

and I guess I would argue that regex is even more unreadable : )

kaosko07:04:44

hello all. I'm using Lein 2.61 w/ Java 1.8.0. I have a mixed clj/java project and everything works great in development when I do lein:run. however, lein uberjar doesn't find my java classes as if they are not compiled or not in the classpath. I've specified a default :java-source-paths. any idea what could be the problem?

mbjarland07:04:55

@kaosko how does your :java-source-paths line look...strange though, since lein:run works...

kaosko07:04:44

@mbjarland :java-source-paths ["src/java"]

mbjarland07:04:46

@kaosko I'm sitting in a project with a similar setup and it is picking up the java class

kaosko07:04:48

@mbjarland yeah, the issue is that it works fine when I do lein run for example, so I'm baffled

mbjarland07:04:30

the following illustrates a working scenario:

[email protected]:~/projects/clojure/clojure-license-plates [master|✚ 2 …3]$ tree src/
src/
├── clojure_license_plates
│   ├── core.clj
│   └── typing.clj
└── java
    └── mxy
        └── IntTools.java

3 directories, 3 files

✔ [email protected]:~/projects/clojure/clojure-license-plates [master|✚ 2 …3]$ lein uberjar
...
Created /home/mbjarland/projects/clojure/clojure-license-plates/target/clojure-license-plates-0.1.0-SNAPSHOT.jar
Created /home/mbjarland/projects/clojure/clojure-license-plates/target/clojure-license-plates-0.1.0-SNAPSHOT-standalone.jar

✔ [email protected]:~/projects/clojure/clojure-license-plates [master|✚ 2 …3]$ unzip -l target/clojure-license-plates-0.1.0-SNAPSHOT-standalone.jar  | grep mxy        0  2017-04-25 09:42   mxy/
     1102  2017-04-25 09:42   mxy/IntTools.class
     1775  2017-04-18 08:42   mxy/IntTools.java
        0  2017-04-18 08:42   java/mxy/
     1775  2017-04-18 08:42   java/mxy/IntTools.java

mbjarland07:04:56

@kaosko example mini-project where this works for whatever it's worth: https://bitbucket.org/mbjarland/clojure-license-plates

ska07:04:30

Hi. Does anyone here have experience with clj-http-fake? Maybe pointers to real life examples?

kaosko07:04:45

@mbjarland thanks. my build is somewhat complex. must be some specific version, setting or plugin throwing a wrench, perhaps lein-virgil? I guess I just need to start excluding things

mbjarland07:04:04

@kaosko well share the findings once you figure it out, sounds like a tar pit preferably avoided : )

ska07:04:21

I wonder if clj-http-fake works, when the calls to the fake HTTP server are in a completely different namespace and way down the stack. The way, fake is writting (using robert.hooke), I would expect it to work, but somehow it doesn't for me.

kaosko07:04:36

@mbjarland will do. changing/excluding virgil had no difference though

jumar07:04:32

@ska it should work as long as you wrap your call within with-fake-routes

ska07:04:45

@jumar, after loading clj-http-fake the metadata of clj-http.core/request seems to be unchanged. But it should have the ::hooks of robert.hook, shouldn't it?

jumar07:04:36

I don't know the internals, but I used it once for "integration" tests - let me check if I can find the example

jumar07:04:30

I used something like this:

ska07:04:31

@jumar, I managed to get something like your code to work, too. But now I try to apply it to real world code where my HTTP calls (using clj-http) are behind a core.async channel, on a different thread and everything. But, as I said, if the instrumenting of clj-http.core/request worked, I'd expect the more complicated setup to be no problem.

ska07:04:54

And yes, I use with-global-fake-routes-in-isolation 🙂

jumar07:04:49

ah, okay - the async stuff can be a problem I guess, but I don't really have experience with this scenario, so sorry O:-)

mbjarland08:04:45

answering my own clojure.spec question above, it seems if you view strings as sequences of chars things work out fine

melindazheng08:04:59

Any Clojurians from Singapore? Please do join #clojure-sg channel.😀

mbjarland08:04:08

<moved to the spec channel>

qqq09:04:33

@tbaldridge : re 'boot clean' vs 'rm -rf ' // I just realized one advantage of 'boot clean' -- nothing bad happens if the machine you think you're SSH-ed into is DIFFERENT from the machine you are actually SSH-ed into

karol.adamiec09:04:26

from time to time i get into a problem that lein works (with plugin for ring ie). but lein uberjar fails. right now my uberjar compilation fails because ‘java.lang.ClassNotFoundException: ring.util.time, ’. That disparity is annoying a bit. what strategy do you use to not make that blunder, and how do i find out what package to import in project.clj ? with version that is current?

karol.adamiec09:04:34

the docs do not seem to be helpful. there is a chasm between packages with version and namespaces. most docs focus on namespaces… so what do you do??

karol.adamiec09:04:16

actually it gets worse, i assumed that i need to pull in a lib “ring.util” in project.clj, but looking into compojure project.clj i see it has ring.core in it and that ring core has utils.time in it. ??

dominicm09:04:37

@karol.adamiec Do you have any dev dependencies? They might be what is bringing in ring.util, and those aren't available during uberjar

karol.adamiec09:04:07

it was not what i thought

karol.adamiec09:04:56

basically (ring.util.time/formatDate …) worked in repl, and with lein server ring. but failed compilation with uberjar

karol.adamiec09:04:43

for compilation to work in uberjar ‘mode’ i had to declare (:require [ring.util.time :as time])

karol.adamiec09:04:10

i pull in my project clj compojure and jetty adapter etc

karol.adamiec09:04:49

so that is a bit of a surprise… i clearly misunderstood some tidbit so any explanation or redirect to one of that behaviour would be appreciated

dominicm09:04:22

@karol.adamiec You hadn't required the namespace. Sometimes namespaces get loaded by other things, but there's no guarantee of ordering. That is why it worked in the repl.

dominicm09:04:31

In general, if you're using a namespace, you must require it.

karol.adamiec09:04:02

ok, good rule of thumb 🙂. got deceived by it working 🙂

isankhairul10:04:56

i am trying clj-http/request, but i look error when request post “Premature end of Content-Length delimited message body (expected: 5047; received: 3943”

isankhairul10:04:21

how any solution ?

ska11:04:16

Answering myself here after a detour to the core.async channel: Do not use with-global-fake-routes when your HTTP call is somewhere behind async channels. But the normal with-fake-routes seems to work (so far). Reason is with-redefs in the end.

not-raspberry12:04:19

@isankhairul That's a problem with the server/connection, not client.

not-raspberry12:04:38

You can maybe do a raw request, read its stream until you cannot, and then retry with an offset equal to how much you managed to read. Repeat that until everything is read.

not-raspberry12:04:12

This will only work if the server understands requests with offsets.

not-raspberry12:04:59

Ofc. you can also keep retrying the full requests until it succeeds.

Tim13:04:09

is there a way to use read-string so it reads multiple forms in the same string?

=> (read-string "(+ 2 2) (+ 5 5)")
(+ 2 2)

Tim13:04:37

Oh I guess I have to parse the string first somehow? there should be an easy way to do this

rauh13:04:52

You can just wrap it in [ ... ]

curlyfry13:04:30

Does anyone here use https://github.com/AvisoNovate/pretty with https://github.com/jakemcc/lein-test-refresh and https://github.com/pjstadig/humane-test-output ? There seem to be some form of collision when running all three of them. humane-test-output is supposed to print the diff when a test fails, but doesn't after I've called io.aviso.repl/install-pretty-exceptions. The diff is displayed as expected when I run regular lein test. Maybe the (RT/loadResourceScript "clojure/test.clj") in https://github.com/AvisoNovate/pretty/blob/master/src/io/aviso/repl.clj#L55 is a suspect?

dominicm15:04:40

@tmtwd I think the proper way to do this is use a StringReader, and repeatedly call (read) on it until you get an EOF

Tim15:04:01

yeah, maybe

jstew15:04:48

It's easy enough to make sure that the string is a single form instead of 2 forms. IMO.

dominicm15:04:43

Except when the form is invalid for example.

dominicm15:04:46

Then you lose everything

jstew15:04:30

Good point.

jstew15:04:37

Depends on what tmtwd wants to do with the input, I suppose. If it's from an untrusted source, they will be validating that it's nothing nasty first.

Tim15:04:54

I was actually reading a .clj file

Tim15:04:02

that had multiple forms

Tim15:04:25

I figured out a different way to deal with it though

dominicm15:04:31

@tmtwd If you want my advice, do it the way I linked, and maybe with tools.reader too, it has additional metadata on read forms.

bradford15:04:29

I’m building a ring svc that needs to take a multipart-form binary upload (like a jpg), and then send that to another REST service which ultimately renders it as a file. Is all I need to do take the (:upload (:multipart-params request)) and make that the content of the next request, + copy over the content-type?

jeff.terrell15:04:50

That sounds reasonable to me. I'd give it a shot and see if it blows up. :-)

stardiviner16:04:56

How to use Clojure 1.9.0?

tbaldridge17:04:34

@stardiviner in your project.clj file change the clojure version to "1.9.0-alpha14"

bostonaholic17:04:33

alpha15 is available

stardiviner06:04:04

I tried, but it still use 1.8.0, Here is my project.clj

clojure
(defproject clojure-examples "0.1.0-SNAPSHOT"
  :description "FIXME: write description"
  :url ""
  :license {:name "Eclipse Public License"
            :url ""}
  :dependencies [[org.clojure/clojure "1.9.0-alpha12"]])

stardiviner06:04:46

Is there some reason in ~/.lein/profile.clj?

stardiviner06:04:48

How can I use Clojure 1.9.0 in ~/.lein/profile.clj ? After a clean profile.clj, I start lein repl in a project project.clj, Now CLojure uses 1.9.0-alpha12.

bostonaholic14:04:31

A couple things. 1) make sure you’re using profiles.clj, (you’re missing the ‘s’) 2) for overriding clojure, you need to use ^:displace e.g. {:repl {:dependencies [^:displace [org.clojure/clojure "1.9.0-alpha12"]]}}

stardiviner03:04:16

Thanks, ^:displace metadata works for me. This is really great.

kaosko17:04:43

hey is anybody here doing Dokku deployments?

kaosko17:04:38

trying it out the first time on my server.. having problem with something simple: Removing intermediate container 7923c371099b Step 3/5 : ADD target/uberjar/xxx.jar /xxx/app.jar remote: lstat target/uberjar/xxx.jar: no such file or directory

kaosko17:04:40

(so I'm trying to push to Dokku. a sample app works, my custom one doesn't) sounds like it should be a simple fix but don't know what I need to change

noisesmith19:04:01

@kaosko check out what is in your target/ directory - many project.clj configs don’t create a separate uberjar directory

kaosko20:04:15

@noisesmith figured it out - I had created my project from a Luminus template and it container a Dockerfile that screwed up dokku deploypment. it was enough to remove it

kaosko20:04:38

cointaner -> contained

josh.freckleton21:04:36

what is the -U flag in lein -U uberjar?

csm21:04:27

lein -h -> -U Run a task after forcing update of snapshots.

josh.freckleton21:04:35

@csm (oh, duh, thanks. we need a "Let Me CLI That For You")

csm21:04:00

I was curious myself what that flag meant…