Fork me on GitHub
#announcements
<
2022-02-07
>
pfeodrippe12:02:00

If you have been using https://github.com/pfeodrippe/pitoco to infer Malli schemas for your Clojure code, a complementary tool was released, https://marketplace.visualstudio.com/items?itemName=feodrippe.pitoco-extension&amp;ssr=false#overview (https://github.com/pfeodrippe/pitoco-vscode-extension). This extension leverages information that you produced when inferred the schemas, allowing you to visualize data at your VSCode environment. It works with the web version of VSCode (http://vscode.dev), the main use case is that you have committed Pitoco schema files generated by pitoco.instrument/store-instrumented-vars! (locally or from your CI) and, for example, when you are reviewing a PR, you press . and then you can hover over your var anywhere and have schema + examples right away without the need to specify any of them beforehand, everything is collected from runtime. It's simple and rough right now, but take a look, report an issue, open a PR o/ See a short video about it at https://www.youtube.com/watch?v=H1An2edqiJk.

clojure-spin 10
🎉 5
😻 1
malli 1
borkdude12:02:07

@U5R6XUARE That's awesome! I've been thinking about something like this for clj-kondo as well. It could generate an HTML view or overlay for code with references to other vars, etc.

❤️ 4
borkdude12:02:33

Similar to how github has some navigation features for some popular languages, but unfortunately not clojure

👍 1
pfeodrippe12:02:01

Yes, exactly!! I was thinking in creating some web view first, but hover was simpler. Clj-kondo could benefit a lot from it, I like the idea!! The extension is made in cljs, I have missed the REPL ahahaha

borkdude12:02:33

I mean, the clj-kondo analysis can be exported to JSON and then be shown in this JS extension or so

borkdude12:02:29

I have asked Github on Twitter once if they would support something like this for their UI: just some files in the repo with information about the code which can be used by their navigation,etc feature

borkdude12:02:58

But they were adamant that everything was implemented in terms of treesitter

pfeodrippe12:02:05

Yes yes, it would be great! One issue I was having is where to store this information, at the moment it reads locally from a committed file, but I am thinking in adding supported for S3 so people can have their commits clean (no generated file with megabytes of information committed).

borkdude12:02:38

yeah, s3 or google cloud

borkdude12:02:57

whatever, could be configurable as long as you have a URL with a file to download

ikitommi14:02:34

nice! Malli itself can do some basic inferring of schemas based on malli schemas or arglists. Maybe that could be plugged in too?

(defn kikka
  ([a] [a])
  ([a b & cs] [a b cs]))

(md/infer #'kikka)
;[:function
; [:=> [:cat :any] :any] 
; [:=> [:cat :any :any [:* :any]] :any]]

ikitommi14:02:56

(mx/defn kukka :- [:vector :int]
  ([a :- :int] [a])
  ([a :- :int, b :- :int, & cs :- [:* :int]] [a b cs]))

(md/infer #'kukka)
;[:function
; [:=> [:cat :int] [:vector :int]] 
; [:=> [:cat :int :int [:* :int]] [:vector :int]]]

pfeodrippe14:02:50

Yes, I'm using the wonderful malli.destructure ns in the extension, it works pretty well :)

ikitommi15:02:01

oh, didn’t notice, cool 😎

robert-stuttaford06:02:01

living in the future!

🚀 1
mauricio.szabo18:02:03

Hi folks! One day I found out a tool that converts JS to ClojureScript, but unfortunately it didn't support most of JS features. I decided to hack on it, found out that it was written in JS, could not find my way around the code, so I decided to do a rewrite: https://gitlab.com/mauricioszabo/js2cljs This is the live version: https://mauricioszabo.gitlab.io/js2cljs/

🎉 12
🔥 10
mauricio.szabo18:02:47

BTW, I accept help from people that know more about UI design to make it better :rolling_on_the_floor_laughing:

😄 1
kipz18:02:29

Cool! Why do you need this out of interest? To be nice to your eyes when reading JS?

trollface 1
Aleed19:02:00

i was looking for something like this when reading js documentation that I wanted to copy to cljs. so good to know it exists the specific case was copying jsx logic to cljs, which may be more difficult to support given various ways it could be written 😅

borkdude19:02:25

Impressive!

1
borkdude19:02:23

@U3Y18N0UC I tried what it would make for class Foo {}

(modern/defclass Foo (constructor [this]))

mauricio.szabo19:02:54

Yeah, that's the [shadow.cljs.modern :as modern] require that I'm not importing yet 😅

mauricio.szabo19:02:52

@UPH6EL9DH the problem with JSX is that it's not really Javascript, so... you need to Babel first 😞

borkdude19:02:48

you can find online JSX translators as well, but I would find that a nice bonus for the online version

borkdude19:02:07

JSX -> Reagent

mauricio.szabo19:02:10

Yeah, I intend to add some configs in the future, like, "convert all objects to CLJS" (right now it tries to keep JS structures intact for example)

mauricio.szabo19:02:21

That's why JS destructuring becomes so weird 😄

borkdude19:02:27

I've actually pondered if I should support some kind of JS like language for babashka for people who want to use the libraries/Java classes, but can't write Clojure. So far the answer has been no every time, but with this as front-end, it could be fun ;)

borkdude19:02:02

But I guess you would soon run into issues like Thread.sleep(1000) -> (Thread/sleep 1000) vs (.sleep Thread 1000)

Aleed20:02:13

what’s a use case for people who know only JS wanting to use Java classes?

borkdude20:02:20

JS/Java-ish syntax may be more familiar to them

mauricio.szabo23:02:01

BTW, thanks for multiple comments, I found and fixed some bugs :D

slipset09:02:22

It would be really handy for me if we could make it work both ways, as a Clojurist dabbling in JS from time to time 🙂

borkdude10:02:27

@U04V5VAUN CLJS already translates clojure into JS ;)

😆 1
jaide19:02:24

This is awesome!

Chris McCormick09:02:51

@U04V5VAUN you might be interested in https://github.com/wisp-lang/wisp which outputs JS from clojure-like lisp.

Akiz17:02:21

Cool! This is probably outside of the scope but this

String(count) + " times"
is formated as
(+ (String count) " times")
It would be nice to get
(str count " times")