Fork me on GitHub
#planck
<
2016-06-08
>
johanatan01:06:44

hi, is core.async supported on planck? I am getting namespace not found on cljs.core.async

mfikes02:06:33

@johanatan: There is a port called Andare that works with bootstrap ClojureScript: https://github.com/mfikes/andare

johanatan02:06:38

@mfikes: how would I go about adding andare as a dependency?

johanatan02:06:12

[I'm not using lein or boot or anything as it's a pretty simple script: in fact, here's the entire project: https://github.com/johanatan/screencap ]

mfikes02:06:03

@johanatan: just download the JAR and use Planck's -c option with the JAR

johanatan02:06:15

ahh awesome! thx!

johanatan02:06:08

by download, you mean clone the src and build the .jar myself? or is it hosted somewhere?

mfikes02:06:12

@johanatan: It is on Clojars… hmm is there a way to just download directly from there without any other tooling?

johanatan02:06:24

oh, ok. i'll take a look

mfikes02:06:07

If you have lein, you can make a small project.clj file specifying [andare "0.1.0”] just to get it

johanatan02:06:32

ok that would work. thx!

johanatan02:06:17

btw, is there an async version of sh ? i'm guessing not since there wouldn't really be any way to express that without andare

mfikes02:06:59

@johanatan: Also, once you set up Planck to use it you’ll definitely be interested in Planck’s ability to cache with -K or -k /some/path/to/cache-dir, otherwise it can take 15 seconds or so to load the core.async namespaces

mfikes02:06:43

No, none of the side libraries in Planck currently offer callback-based async support.

mfikes02:06:56

(In fact, Andare was created after planck.http)

mfikes02:06:29

But, you could imagine an async sh which called back with the results instead of returning them

johanatan02:06:38

this is really nice btw. way better than using bash or python or what have you

mfikes02:06:09

Yes. To be honest, I never can remember how to even build up strings in Bash. In ClojureScript we all know it is done with str 🙂

johanatan02:06:12

case statements are a disaster in bash too

noonian02:06:26

It really makes bash utilities way more useful to me since I never learned/internalized enough bash to do anything reasonably complex. Even something as trivial as iterating over the output lines from ls goes a long way. Especially when you can do that sort of thing to get some input data or what have you and then you’re back in Clojure.

mfikes02:06:51

@johanatan: That’s a cool script. Yes, you should be able to use cljs.core.async/timeout to make your loop at the bottom sleep a bit before looping back around

mfikes02:06:12

@noonian: Yes. One thing that shows just how far we have come with ClojureScript (and is close to your example) is the one-liner in https://gist.github.com/mfikes/9503aa2555aac1cafaf4 where Rich’s demo involved first AOT-compiling some code and then running it in Node

noonian02:06:57

Quite amazing 🙂

johanatan06:06:44

Ran into a little snag: having just a top-level go routine with infinite loop inside returns immediately (whether or not it is inside a main and -m is passed).

johanatan06:06:16

When I do this from a regular Node.js ClojureScript project, it works as expected-- i.e., the program hangs while the go routine handles all processing rather than exiting immediately.

mfikes13:06:01

@johanatan: Thanks! Fix pushed to master. Now code like the following will keep script processing “alive” until complete:

(go
  (loop [n 10]
    (when (pos? n)
      (<! (timeout 1000))
      (println n)
      (recur (dec n)))))
You can brew master (see http://planck-repl.org/setup.html) or let me know if you’d just like a binary you can download.

fasiha14:06:16

Reading @johanatan's screencap—did not realize that planck included goog.*! I realized I have a very hazy idea about the differences between Planck/JavaScriptCore and "regular Cljs"/Google Closure

mfikes14:06:35

@fasiha: Yeah, it is most of the Google Closure library

fasiha14:06:51

Uh oh, most? 🙃

mfikes14:06:33

If interested, here is how Planck includes stuff in its binary: http://blog.fikesfarm.com/posts/2015-07-27-island-repl.html

fasiha14:06:33

I've had this feeling before (the surprise at finding out google closure was included), when I found out Planck included transit

fasiha14:06:43

It's like Aladdin's cave

mfikes14:06:49

Yes, Transit is kind-of exposed by accident. I should probably just commit to it being there and list it in http://planck-repl.org/dependencies.html

mfikes14:06:17

I haven’t thought of a good way to cope with the fact that some of the things that Planck uses are simply available to Planck end-users.

mfikes14:06:20

In terms of what “most” means wrt Google Closure, stuff is pulled in intentionally here: https://github.com/mfikes/planck/blob/master/planck-cljs/src/planck/bundle.cljs

fasiha14:06:59

@johanatan: I don't think you have to do the stuff with st and eval in screencap's main.cljs just to read in the EDN config. This seems to be sufficient: (1) add [cljs.reader] to your requires, and (2) (def config (cljs.reader/read-string (slurp "./config.edn")))

mfikes14:06:17

FWIW, there is also planck.core/eval and I’m working on adding read if it proves to be useful: https://github.com/mfikes/planck/commit/f1b8547bf2a42bc06d04e81d52048555ba223c60

johanatan16:06:11

@fasiha: ahh, nice. Ya I tried to get reader to work but didn't stumble onto that particular incantation I suppose

johanatan16:06:12

Doesn't help that everything returned from google when searching for 'ClojureScript reader' involves the 'reader conditional'

fasiha17:06:45

The words 'magic' and 'Clojure' go together uncomfortably often 😕

noonian17:06:37

"Any sufficiently advanced technology is indistinguishable from magic.” 🙂

fasiha17:06:47

@mfikes: I'm reading Clojuredocs for read and read-string side by side trying to understand the difference—it looks like the former consumes something not-stringy, a "push-back reader"?

fasiha17:06:00

I'm guessing reading a Clojure expression from a stream, then unreading it (pushing it back) is useful even though I can't see how.

mfikes17:06:21

@fasiha: I think it is just a concession that makes a reader easier to implement. For example, when reading 17(+ 2 3) the reader starts parsing the number at the beginning, but then it hits the ( and concludes that the number 17 has been fully parsed and simultaneously puts the ( back on the stream, unwinds the stack and continues, starting afresh with (+ 2 3) in the stream.

fasiha17:06:55

@mfikes, OH that is useful, got it! Thanks for explaining