Fork me on GitHub

How many folks test all the examples in their README files? Do you automate that? Are there any alternatives to midje-readme for that sort of thing?


yes. I do it manually copy and paste when preparing a new release.


@U1QQJJK89 Would you use a clojure.test-compatible tool that could automate README example testing appeal to you?


yes but it would need to test shell command invocation. here I cd into the quickstart directory of the project and run commands:


in other cases I would be testing clojure code directly though


Haha... okay, that's an interesting use case... I was talking more about pure Clojure code in the readme, in the context of the project itself, so it would only pay attention to chunks of code wrapped in three back ticks and clojure 🙂


I've used midje-readme on a couple of projects (and I do not like midje!) and it seems to be the only game in town and it does have several caveats 😕


selecting the backtick blocks by clojure annotation would work. shell blocks could be handled seperately.


True. Not sure the latter is in my scope right now but it's an interesting option to consider.


Just solve the clojure case, and leave the shell case for my pull request 😉

parrot 4
💯 4

I've been working on a thing that can turn Clojure code blocks in Markdown and AsciiDoc code blocks interactive: I've shelved it for the moment, probably mainly because I don't know whether it's actually useful for anyone (hence the name). You could use it to test code blocks in your README, though.


(I realize it's not exactly what you're looking for, though.)


Oh, I see you already went ahead and made a thing of your own — cool!


Yeah, the first version is fairly simplistic. I dreamed of some richer approaches overnight so seancorfield/readme will evolve quite a bit over the next day or two I suspect 🙂


seancorfield/readme {:mvn/version "1.0.12"} -- -- I ended up writing a thing to turn README files into tests 🙂

👀 4

Anyone tried to use with Clojure


@borkdude hats off to you! I had written my own tiny Clojure-based DSL for generating SVG diagrams as part of the Asciidoctor/Antora pipeline, and as much fun as I was having implementing the various special forms, someone pointed me at sci and I ripped out my own code and integrated yours, producing a much more feature-filled, yet still safe and usable in a JavaScript pipeline, language. 🔥


there is no =print-method= in the core api page


is that suppose to be an api?


and also stuff like print-simple

Alex Miller (Clojure team)04:03:56

print-method is not included because it's not doc'ed, but it probably should be. it's really more of an spi method than api (for hooking into the print system)

Alex Miller (Clojure team)04:03:40

ditto print-dup which is equally as important

Alex Miller (Clojure team)04:03:55

things like print-simple and print-ctor, probably not but I'd have to look at it more


thanks for your work.


Hi all, I have a REST application in clojure and I want to use oauth2 to authorize incomming requests. can you suggest some libraries?


What’s the best way to handle a java.lang.Iterable that blocks forever - (representing a stream of changes from a mongo database)? Obviously need to spawn it in a separate thread but not sure if I should just use doseq — and how to deal with cancellation…


wdyt of this pattern?

(def q (queue-of-your-choice))

(def enqueuer (future
                (while (not (-> Thread/currentThread) .isInterrupted)
                  (let [v (take-value-from-mongo)]
                    (put! q v)))))

(comment (future-cancel enqueuer))
(queue-of-your-choice) could be java blockingqueues, or a core.async chan etc Idea being, you deal with the mongo iterator in a very delimited part of your codebase, and the rest of the codebase consumes a vanillla queue, with more familiar semantics, and importantly with blocking/timeouts so that production and consumption don't run at disjointed rates


That’s a good call — and I found out that Iterable can give me an Iterator which has a plain next call.

👍 4

doseq seems to be doing the lazy chunking of 32 items at a time, which I don’t want, I want to consume the next time as soon as it’s available.

👀 4

i need to write a bunch of lines to a file generated from application data ... is there a "nicer" way than opening an io/writer and chaining calls to (.write w stuff) with (.write w "\n")?


Can’t you just use

(binding [*out* w]
  (… normal Clojure print, println, et. al. calls …))


what’s the purpose of emphasizing free of side effects?


Usage: (iterate f x)
Returns a lazy sequence of x, (f x), (f (f x)) etc. f must be free of side-effects


f x may be invoked multiple times


And at unpredictable times because of chunking, no?


I don't think it will be called multiple times. But delayed and chunked calls are a possibility.


In short, don't mix lazy sequences and side effects.


Looks like iterate just wraps a call to clojure.lang.Iterate/create, which is an interesting read


Thanks for the link. Forgot that iterate is not chunked.


it can be invoked multiple times -- the reducible path doesn't cache


I thought I was going crazy for a second

Alex Miller (Clojure team)15:03:40

yeah, the result of iterable can be accessed as a seq and reduced over and those two paths do not share values

Alex Miller (Clojure team)15:03:58

doing both is probably uncommon


does clj-http auto decode base64 on the response body?


Of course, that's just a suggestion. I could be missing something.


that's weird, because on the browser i receive an encoded body resp, and with clj-http i receive it decoded


In the browser? So cljs-http?


no, i mean, i make the request with Firefox, navigating the page


and using the dev tools i can see it returning a Base64 string as response body


but the same request with same headers made in clj-http returns the same content but it's already decoded


the problem is that in this decoding process it uses the wrong encoding format, and i lose some characters such as ^ ~ `


Are you certain that the server is sending the same Base64 string when you're calling from a Clojure runtime? Any chance there are differences in the request, like Accept headers, etc?


i literally copied the same ones that the browser request is using


i didn't said but, the response is a CSV file


maybe Firefox is doing something and encoding this as base64


Could also be happening in deps of clj-http


Lots of possible places where the requests and/or responses differ.


all of that wouldn't be a problem if i could take this string that i receive on CLJ-HTTP and get back those missing characters ~` instead i get some ? characters in place of them, this is ruining my parsing process


could it be that the implicit stringify is using the wrong text encoding?


clj-http add's lot's of headers for us, maybe something is going on there


yes @noisesmith that's what i think, but where is this implicit stringify?


if you use the :as :input-stream option to clj-http, you'll be able to consume and convert it in whatever way you like

👍 4

let me look up the actual option...


ok! i'll give it a try


the option is {:as :stream} - then it's your job to consume the stream, convert, etc. etc.


i'll try to use slurp in it passing the right encoding


there's also {:as :byte-array} which also won't do any text conversion and might be more convenient


eg. the base64 decoder that comes with java takes a byte-array


assuming this will return the base64


well let's see


found a way much more simple


{:as "iso-8859-1"}

👍 4

then it came on the right format


seancorfield/readme {:mvn/version "1.0.12"} -- -- I ended up writing a thing to turn README files into tests 🙂

👀 4

I have a coworker that wants to learn functional programming concepts but in javascript/typescript language. Has anyone come across a good course or book?

Nir Rubinstein20:03:17

You can have FP concpets in almost any language (higher order functions, expressions vs. statements, referential transparency etc.), but some languages "lend" themselves to it much better than others. For me, the crux of the matter lies in immutability which JS or TS don't have so it'll be much harder... If he wants to learn it on the FE side, he can try Clojurescript/Elm/Purescript etc.


I've convinced him that it is worth learning but can't convince him to pick up a new language

Michael J Dorian20:03:57

For what it's worth, lots of people in my local dev group love functional programming in JS. I would say it's the most popular language for functional programming in my tiny town simple_smile


@U5136PEE6 Point him at Grokking Simplicity by Eric Normand. It's a work in progress right now but it uses JS to illustrate the concepts and it's really well thought out.

Bobbi Towers11:03:48

And speaking of which, Functional JavaScript by Michael Fogus, while kind of outdated, was a very good read

Bobbi Towers11:03:26

I heard that this is great for functional JavaScript


i've tried lot's of them, never had success in trying to learn FP concepts with JS


because you can mix paradigms, when i tried, things tend to become a mess and i always got lost in the process


is it possible to write a macro which gets the calling function? I am thinking of using ~(meta &form) implicit macro var and *file* . Maybe it is possible to to combine those variables and infer the calling function. Or maybe there is an other way? :thinking_face:


what are you trying to achieve?


@ghadi I want to make log framework macro that shows tha calling function


You can get the calling function from the stack info, but I think it might add quite a bit of overhead

✔️ 4

Java 14 brings an option for "helpful null pointer exceptions" -- how might it affect Clojure? See for an example.

parens 8
Alex Miller (Clojure team)23:03:27

that was my guess when I read about it too

Alex Miller (Clojure team)23:03:54

in Java, it is certainly better than the message "null" :)


Yeah. Some of those messages could be greatly improved by small refactorings of the Java code in Clojure's runtime and/or compiler but I'd be suspicious of those changes slowing Clojure down.