Fork me on GitHub
#nbb
<
2022-10-13
>
Daniel Gerson08:10:57

Morning. I suspect the following promesa snippet isn't right?

(p/done? (p/rejected (ex-info "test" {})))
  ;; => No protocol method IState.-pending? defined for type object: [object Promise]

borkdude09:10:53

lemme check

borkdude09:10:00

I get the same error in regular CLJS so it's not nbb-specific at least

Daniel Gerson09:10:09

(meant one thread down 😆 )

borkdude09:10:11

cljs.user=> (p/done? (p/delay 100))
Execution error (Error) at (<cljs repl>:1).
No protocol method IState.-pending? defined for type object: [object Promise]
Perhaps file an issue with promesa

Daniel Gerson09:10:03

Thanks for checking.

Benjamin19:10:18

the cljs.core library is not present in nbb, scittle nor joyride is that correct?

borkdude19:10:18

it's called clojure.core in all of those

Benjamin19:10:42

(defun cider--check-cljs (&optional cljs-type no-error)
  "Verify that all cljs requirements are met for CLJS-TYPE connection.
Return REPL-TYPE of requirement are met, and throw an 'user-error' otherwise.
When NO-ERROR is non-nil, don't throw an error, issue a message and return
nil."
  (if t
      (condition-case ex
          (progn
            (cider-verify-clojurescript-is-present)
            (cider-verify-cljs-repl-requirements cljs-type))
        (error
         (message "Invalid ClojureScript dependency: %S" ex)
         nil))
    (cider-verify-clojurescript-is-present)
    (cider-verify-cljs-repl-requirements cljs-type)))
I can make a quick hack with this function, be ok with cljs.core not being there and i get a nice nbb repl

borkdude19:10:20

Well, this does work: cljs.core/inc in all of those environments. What exactly does CIDER execute?

Benjamin19:10:52

(defun cider-verify-clojurescript-is-present ()
  "Check whether ClojureScript is present."
  (unless (cider-library-present-p "cljs.core")
    (user-error "ClojureScript is not available.  See  for details")))
checks "cljs.core"

borkdude19:10:35

Perhaps you can convince CIDER to change this into cljs.core/inc which does work for SCI CLJS environments

borkdude19:10:45

In JVM Clojure you can't just type clojure.core and expect a result, so this isn't implemented. It seems more an artifact than a supported feature in CLJS

Benjamin19:10:41

you know what is funny? I think the only issue is that most repls return "nil" and nbb returns nil when evaling a require function call

Benjamin19:10:23

ah nvm. I tries to eval (require 'cljs.core)

Benjamin19:10:47

for completeness, here is my cider proposal https://github.com/clojure-emacs/cider/issues/3255

mkvlr20:10:56

@U02CV2P4J6S really appreciate your efforts here, would love to see the default experience improve here, thank you! 🙏

1
😅 1
✔️ 1
Benjamin12:10:25

turns out I needed to workaround a little more. This elisp should work, should somebody desire a jack-in-nbb command right now: https://benjamin-asdf.github.io/faster-than-light-memes/jacking-nbb.html

borkdude12:10:10

@U02CV2P4J6S Cool, worth sharing here in the main channel. I'll also link it from nbb's README

👍 1
Benjamin19:10:53

(defun mm/cider-connected-hook ()
  (when (eq 'nbb-or-scittle-or-joyride cider-cljs-repl-type)
    (setq-local cider-show-error-buffer nil)
    (cider-set-repl-type 'cljs)))

(add-hook 'cider-connected-hook #'mm/cider-connected-hook)

(defun mm/cider-jack-in-nbb ()
  (interactive)
  (cider-jack-in-cljs
   '(:jack-in-cmd
     "nbb nrepl-server"
     :cljs-repl-type
     nbb-or-scittle-or-joyride)))
because this kinda works good. Except that cider checks for cljs.core lib and throws an error.