Fork me on GitHub
#announcements
<
2022-09-21
>
quoll03:09:35

Clormat 0.0.1 A clean reimplementation of clojure.core/format for Clojure/ClojureScript Repo: https://github.com/quoll/clormat This covers some of the basic functionality of the format function, specifically for ClojureScript. It's an initial release, covering positional parameters, along with several of the datatypes and flags. Significantly, it is still missing floating point formats and date/times, but these are in progress. The function aims for clojure.core/format compatibility wherever possible.

🎉 31
🆒 9
clojure-spin 8
👍 5
bmo 3
Cora (she/her)04:09:51

so cool!!

💖 1
quoll04:09:52

It's ridiculously finicky

quoll04:09:51

Like, what should this return?

(format “%,(010d” -101)
I thought maybe ”(000,101)” because it can't be ”(,000,101)” but it turns out that prefixing zeros don't get grouped, even though the NumberFormat classes on both Java and JavaScript DO group prefixing zeros

Cora (she/her)04:09:04

matching behavior like this is so hard. thanks for doing it 💜

quoll04:09:48

Or… how should -1 be represented in hex? It can't be 64 bits wide because integers on JavaScript are only 52 bits wide

Cora (she/her)04:09:09

oh god I didn't even think of that

quoll04:09:49

I did say “ridiculously finicky”

Cora (she/her)04:09:09

an understatement, I'm sure

😆 1
Cora (she/her)04:09:45

if anyone can figure it out, though, it's you

💖 1
💯 1
quoll04:09:09

One thing I haven't put a lot of effort into though is incompatible flag combinations

Cora (she/her)04:09:33

how do you mean?

quoll04:09:19

For instance, ”%-010d” says to print a number at least 10 characters wide, left-justified, with leading zeros to make up the width. But if it's left-justified then there can't be any leading zeros

quoll04:09:43

If there are leading zeros then it will take up the whole width and left/right justification won't matter

quoll04:09:09

You know… that kind of thing 🙃

quoll04:09:13

On the plus side, I know much more about formatting text strings than ever before!

Cora (she/her)04:09:24

this just in: found the text formatting goddess

Cora (she/her)04:09:48

I get paralyzed with those kinds of choices tbh

Cora (she/her)04:09:11

and in the end devs need to be aware of at least some of it

Cora (she/her)04:09:44

write once, run anywhere: a god damn lie from the start

doge 1
Lennart Buit07:09:32

Programming in a nutshell: You are walking down the street only to fall in a little pothole that ends up being 3km deep and require a thorough study of spelunking to get out again.

👆 1
😆 1
pez09:09:45

> An implementation of the cljs.core/format function for ClojureScript. Also runs (redundantly) in Clojure. Not sure how I should read this. Should it say an implementation of the clojure.core/format function?

quoll10:09:26

Well it's trying to be an implementation of the missing cljs.core/format function

pez10:09:50

That's awesome. Maybe say that in the README? 😃

pez10:09:25

Also, is clormat a play with the name of cljs.pprint/cl-format?

Noah Bogart11:09:39

Are you trying to do this without reading the openjdk source?

quoll12:09:15

Yes, I am 🙂

quoll12:09:23

The name was probably informed by the existence of cl-format, but I was just thinking “CLojure fORMAT”

Noah Bogart12:09:22

That’s cool and a much harder task lol. Makes sense for licensing reasons if you want to upstream it; you’re a champ for doing this

bherrmann16:09:08

finicky looks like fn-hickey (aka function by Rich Hickey)

quoll16:09:15

Yes… very finicky. I’ve been exploring more, and I now have more info to make it better for localization (correcting expanding with zeros, etc)

😍 1
quoll16:09:12

Every allowable zero: 0٠༠০०۰၀๐᱐

quoll16:09:28

Depending on the country and language setting

pez16:09:05

Is it supposed to format numbers and things according to locale? If so I could have a look at the Swedish.

quoll16:09:22

It’s defined to work against the current default locale, which I have yet to figure out how to set during testing 🙂

quoll16:09:52

There are relatively consistent rules to follow regardless of locale, but not all of it is apparent

quoll16:09:07

Expand with 0s varies according to the number system in use (see the earlier message). Group separators are an issue as well, since they also vary with the numbering system

quoll16:09:43

Somewhat ironically, Arabic does not use the numbers we call “arabic” 🙂

😂 1
quoll16:09:39

For instance, the number 1234 in one form of arabic is: ١٬٢٣٤

quoll16:09:34

The second character is the group separator. European countries are easy enough for me: UK: “1,234”, FR: “1 234", GE: “1.234”

Lennart Buit17:09:53

Although the Dutch uses comma for decimals, and dot for thousands. Exactly opposite of Americans. This has never lead to input confusion for me-as-a-Dutchie

quoll17:09:13

These things are easy, since the digits are all the same

quoll17:09:32

Here are all the possible outcome for (format "%,d" 1234):

"1,234"
"1.234"
"1234"
"1 234"
"1’234"
"١٬٢٣٤"
"۱٬۲۳۴"
"१,२३४"
"১,২৩৪"
"๑,๒๓๔"
"༡,༢༣༤"
"၁,၂၃၄"

😵 1
quoll17:09:51

Extra notes: • clojure.core/format wraps java.lang.String/format which does not accept a locale. This means that it always select the current default, and you cannot control it on this function. • You can control it on the JVM, via: (String/format (Locale/forLanguageTag "sv") "%,d" (object-array [1234])) • You can do the same on JS via: (.format (js/Intl.NumberFormat. "sv" #js{:grouping: true}) 1234) • This is for the trivial case of a pattern of "%,d". More detailed cases cannot be formatted via the locale settings, and require manual intervention. For instance, when using "%,010d" then using locale formatting to ask for 10 digits in the UK will give an output of: "0,000,001,234". However, the format function actually outputs: "000001,234". Note how the localization groups the zeros, but the format does not?

quoll17:09:58

I’m just scratching the surface here

quoll17:09:09

It gets hairier 🙂

Ivar Refsdal07:09:38

clj-paginate 0.2.52 Fast pagination of vectors and maps with Clojure for GraphQL. Easily handles vectors with 10M entries. Repo: https://github.com/ivarref/clj-paginate This release adds support for :sort-fn and with that custom ordering (ascending/descending) of attributes. https://github.com/ivarref/clj-paginate#descending-values-example. It's backwards compatible with the previous release.

🎉 4
clojure-spin 2
jpmonettas12:09:31

[ANN] FlowStorm Clojure[Script] debugger 3.0 is out FlowStorm is a Clojure and ClojureScript debugger with some unique features. Version 3.0 has been redesigned to be much simpler and more extensible. It goes from being a debugger to being a platform for building debuggers + a reference implementation. Most remarkable new features for this version are : • ClojureScript is feature par with Clojure now, so every feature is available to both languages. • Remote debugging can be accomplished by just connecting to a nrepl server (socket repl support on the roadmap) • A programmable API. This means debug your code by writing Clojure code that uses the debugger infrastructure. See (https://jpmonettas.github.io/flow-storm-debugger/user_guide.html#_programmable_debugging) • Opens the possibility for future integration with IDEs/editors Github repo : https://github.com/jpmonettas/flow-storm-debugger/ User Guide https://jpmonettas.github.io/flow-storm-debugger/user_guide.html Big thanks to Roam Research (https://roamresearch.com/) for sponsoring the project! If you have any questions please show up on #flow-storm in clojurians slack PD : I'm planning to make some videos on how to use FlowStorm to debug different kinds of applications (web apis, re-frame SPAs, etc) I hope you find it useful. Cheers!

amazed 14
🎉 24
🚀 14
clojure-spin 13
gratitude 5
😍 2
2
👏 2
Lidor Cohen16:09:33

👏 👏 👏 Been waiting for this thank you so much! 🙏

jpmonettas16:09:41

you are welcome! if you have any questions show up in #flow-storm!

jpmonettas17:09:39

for people that tried it for ClojureScript and was annoyed by having to reconnect the debugger by hand when reloading a browser page or restarting the shadow repl just released 3.0.188 which does automatic connection management. It also shows the connection status for the repl and the runtime on the bottom right corner