Fork me on GitHub
#babashka
<
2023-04-16
>
teodorlu12:04:51

I'm starting to get familiar with babashka/fs, and I it's joyful to work with. The https://github.com/babashka/fs/blob/master/API.md is concise and easy to read. The operations in the babashka.fs namespace compose well. Compared to the manual string operations I've been doing before, fs is so much better! 😸 ❤️

❤️ 8
teodorlu13:04:25

I also really appreciate that babashka/fs doesn't have fluff. It feels like learning to work with the file system, not working with some weird abstraction on top of the file system.

pesterhazy13:04:17

Yeah, it's one of the best libs for doing fs stuff in any language

❤️ 2
pesterhazy13:04:03

I still do string concatenation sometimes (str dir "/" fname) - doesn't seem to hurt

❤️ 2
pesterhazy13:04:22

My understanding is that forward slashes are fine on windows as well > I've never found it documented anywhere, but the JDK classes let you use slashes regardless of whether you're on Windows or not. (You can see this in the JDK source, where it explicitly converts path separators for you.) https://stackoverflow.com/questions/19762169/forward-slash-or-backslash

👍 2
teodorlu13:04:34

Yeah, it plays no nicely with strings. You can use strings or fs objects at any place without hassle, so the abstractions are all opt-in!

teodorlu13:04:04

or you can use babashka.fs/path if you like.

pesterhazy13:04:58

Yeah exactly - that's nice as well, I'm just not sure I want to drag people towards fs/path instead of str in code review

teodorlu13:04:00

Agreed, I think both are fine!

borkdude14:04:04

There are some situation in which slashes don't work on Windows (it might be with mixed backslashes and forward slashes), but I don't remember them off the top of my mind. I think it's usually better to use (str (io/file x "foo" "bar")) or fs/file than doing the string thing manually with (str x "/" "foo")

👍 4
rads18:04:50

Is it possible to use s/instrument and expound together in Babashka? When I try to set it up using alter-var-root the instrumentation is working but the pretty printing doesn't work Example: https://gist.github.com/rads/cad563ed2a14fd1d00be17310dfd6efb

borkdude19:04:49

Is this different from the behavior in clojure?

rads19:04:43

Yes, if I remove the Babashka-specific stuff from my example and run with clojure, I get the following output:

Execution error - invalid arguments to user/foo at (expound2.clj:22).
expound2.clj:22

-- Spec failed --------------------

Function arguments

  ("bar")
   ^^^^^

should satisfy

  int?

-------------------------
Detected 1 error

borkdude19:04:23

Don't know. Worth posting an issue. You can debug by adding babashka/spec.alpha to your deps and then looking into what should happen around the explain-out stuff

rads19:04:50

Sure thing, thanks for confirming

rads19:04:41

I think I figured out why the behavior is different between Clojure and Babashka. It looks like there is behavior in clojure.main/main to run explain-out in the error reporter: https://github.com/clojure/clojure/blob/d0175370c05ef12304aa46236012bc56059c3ddc/src/clj/clojure/main.clj#L326-L341 So it's nothing to do with expound, it's the difference between how Clojure and Babashka print exceptions by default