Clojurians
#lumo
<
2017-07-05
>

This page is not created by, affiliated with, or supported by Slack Technologies, Inc.

anmonteiro00:07:30

btw being on 1.6 means you can use -D / --dependencies (Lumo will look in your local Maven repo for JARs)

anmonteiro00:07:53

e.g. how I started lumo above:

lumo -D reagent:0.7.0,cljsjs/react:15.5.4-0,cljsjs/react-dom:15.5.4-0,cljsjs/create-react-class:15.5.3-0

ericnormand00:07:04

:disappointed:

ericnormand00:07:06

Could not parse ns form reagent.impl.batching in file reagent/impl/batching.cljs
	 (new)
	 Function.cljs.core.ex_info.cljs$core$IFn$_invoke$arity$3 (NO_SOURCE_FILE <embedded>:1935:200)
	 Function.cljs.analyzer.error.cljs$core$IFn$_invoke$arity$3 (NO_SOURCE_FILE <embedded>:2482:92)
	 (NO_SOURCE_FILE <embedded>:5860:394)
	 cljs.js.load_macros (NO_SOURCE_FILE <embedded>:5838:464)
	 (NO_SOURCE_FILE <embedded>:5835:384)
	 Function.cljs.js.require.cljs$core$IFn$_invoke$arity$5 (NO_SOURCE_FILE <embedded>:5793:38)
	 cljs.js.load_macros (NO_SOURCE_FILE <embedded>:5835:41)
	 (NO_SOURCE_FILE <embedded>:5835:384)
	 Function.cljs.js.require.cljs$core$IFn$_invoke$arity$5 (NO_SOURCE_FILE <embedded>:5793:38)

Invalid :refer, macro reagent.debug/assert-some does not exist in file reagent/impl/batching.cljs
	 (new)
	 Function.cljs.core.ex_info.cljs$core$IFn$_invoke$arity$3 (NO_SOURCE_FILE <embedded>:1935:200)
	 Function.cljs.analyzer.error.cljs$core$IFn$_invoke$arity$3 (NO_SOURCE_FILE <embedded>:2482:92)
	 Function.cljs.analyzer.error.cljs$core$IFn$_invoke$arity$2 (NO_SOURCE_FILE <embedded>:2481:92)
	 Function.cljs.analyzer.check_use_macros.cljs$core$IFn$_invoke$arity$3 (NO_SOURCE_FILE <embedded>:2819:314)
	 Function.cljs.analyzer.check_use_macros.cljs$core$IFn$_invoke$arity$2 (NO_SOURCE_FILE <embedded>:2816:114)
	 (NO_SOURCE_FILE <embedded>:5860:108)
	 cljs.js.load_macros (NO_SOURCE_FILE <embedded>:5838:464)
	 (NO_SOURCE_FILE <embedded>:5835:384)
	 Function.cljs.js.require.cljs$core$IFn$_invoke$arity$5 (NO_SOURCE_FILE <embedded>:5793:38)

anmonteiro00:07:52

which namespaces are you requiring?

ericnormand00:07:36

(require 'reagent.core)

anmonteiro00:07:23

That’s odd, since I was able to require it just now

anmonteiro00:07:47

can you wipe your caches?

anmonteiro00:07:50

and try again

ericnormand00:07:34

doing something different now

ericnormand00:07:14

looks like I can make progress now

anmonteiro00:07:33

awesome, let me know if I can do anything more to help

ericnormand00:07:45

ERROR in file ajax/xml_http_request.cljs
	 (new)
	 Function.cljs.core.ex_info.cljs$core$IFn$_invoke$arity$3 (NO_SOURCE_FILE <embedded>:1935:200)
	 Function.cljs.analyzer.error.cljs$core$IFn$_invoke$arity$3 (NO_SOURCE_FILE <embedded>:2482:92)
	 (NO_SOURCE_FILE <embedded>:5947:100)
	 z (NO_SOURCE_FILE <embedded>:5948:13)
	 (NO_SOURCE_FILE <embedded>:5942:232)
	 (NO_SOURCE_FILE <embedded>:5862:482)
	 Object.cljs.js.load_macros (NO_SOURCE_FILE <embedded>:5838:464)
	 (NO_SOURCE_FILE <embedded>:5857:20)
	 Object.cljs.js.load_macros (NO_SOURCE_FILE <embedded>:5838:464)

XMLHttpRequest is not defined
	 (evalmachine.<anonymous>:5:1)
	 ContextifyScript.Script.runInThisContext (vm.cljs:44:33)
	 Object.runInThisContext (vm.cljs:116:38)
	 (Object.lumoEval)
	 lumo.repl.caching_node_eval (NO_SOURCE_FILE <embedded>:6211:68)
	 (NO_SOURCE_FILE <embedded>:5947:29)
	 z (NO_SOURCE_FILE <embedded>:5948:13)
	 (NO_SOURCE_FILE <embedded>:5942:232)
	 (NO_SOURCE_FILE <embedded>:5862:482)
	 Object.cljs.js.load_macros (NO_SOURCE_FILE <embedded>:5838:464)

ericnormand00:07:04

is that because it's node?

anmonteiro00:07:04

right. There’s no XMLHttpRequest in Node

ericnormand00:07:14

it worked before

ericnormand00:07:23

is there any way to output the cached namespace without evaling it?

anmonteiro00:07:24

not that I can think of

ericnormand00:07:51

has anything changed?

ericnormand00:07:00

I'm sure I've required that before

ericnormand00:07:05

Maybe the code has changed

ericnormand00:07:20

I've got to grab dinner now

anmonteiro00:07:03

I don’t think anything has changed

anmonteiro00:07:48

I can’t see how you required a file that depended on XMLHTTPRequest being there

anmonteiro00:07:17

I think I remember this conversation :slightly_smiling_face:

ericnormand01:07:53

the reason I say it must have been generated is that it exists here in the cache:

anmonteiro02:07:47

@ericnormand right. I think I had this conversation with @viebel before

anmonteiro02:07:20

if you install the polyfill and (set! (.-XMLHttpRequest js/global) (.-XMLHttpRequest (js/require "xmlhttprequest"))) it’ll probably work

ericnormand02:07:36

he has custom versions of stuff

ericnormand02:07:23

I should have looked at it before

ericnormand02:07:25

thanks again!

ericnormand03:07:47

does this make any sense to you?

ericnormand03:07:49

WARNING: poppea$macros is a single segment namespace at line 1 poppea.clj
WARNING: cljs.core$macros/bit-or, all arguments must be numbers, got [string number] instead. at line 121 cljs/tools/reader/edn.cljs
WARNING: cljs.core$macros/bit-or, all arguments must be numbers, got [string number] instead. at line 121 cljs/tools/reader/edn.cljs
WARNING: cljs.core$macros/bit-or, all arguments must be numbers, got [string number] instead. at line 122 cljs/tools/reader/edn.cljs
WARNING: cljs.core$macros/bit-or, all arguments must be numbers, got [string number] instead. at line 122 cljs/tools/reader/edn.cljs
No such macros namespace: cljs.tools.reader.edn, could not locate cljs/tools/reader/edn.clj or cljs/tools/reader/edn.cljc in file cljs/tools/reader/edn.cljs
	 (new)
	 Function.cljs.core.ex_info.cljs$core$IFn$_invoke$arity$3 (NO_SOURCE_FILE <embedded>:1935:200)
	 Function.cljs.analyzer.error.cljs$core$IFn$_invoke$arity$3 (NO_SOURCE_FILE <embedded>:2482:92)
	 Function.cljs.analyzer.error.cljs$core$IFn$_invoke$arity$2 (NO_SOURCE_FILE <embedded>:2481:92)
	 (NO_SOURCE_FILE <embedded>:5802:520)
	 Object.lumo.repl.load_other (NO_SOURCE_FILE <embedded>:6201:380)
	 lumo.repl.load (NO_SOURCE_FILE <embedded>:6205:106)
	 Function.cljs.js.require.cljs$core$IFn$_invoke$arity$5 (NO_SOURCE_FILE <embedded>:5804:390)
	 Object.cljs.js.load_macros (NO_SOURCE_FILE <embedded>:5835:41)
	 (NO_SOURCE_FILE <embedded>:5857:20)

ericnormand03:07:07

something is trying to load in the macro namespace

anmonteiro03:07:30

looks very weird to me

anmonteiro03:07:07

I don’t really know what we should do in this case

anmonteiro03:07:20

the poppea namespace is a macros namespace

anmonteiro03:07:14

if this were JVM ClojureScript, you wouldn’t be able to load cljs.tools.reader.edn

anmonteiro03:07:59

^ given cljs/tools/reader/edn.cljs

anmonteiro03:07:08

because macros are written in Clojure

ericnormand03:07:04

how did this ever work?

anmonteiro03:07:35

does it work in klipse?

anmonteiro04:07:50

FWIW Planck throws the same error

anmonteiro04:07:59

lanck 2.5.0
ClojureScript 1.9.660
    Docs: (doc function-name-here)
          (find-doc "part-of-name-here")
  Source: (source function-name-here)
    Exit: Control+D or :cljs/quit or exit or quit
 Results: Stored in vars *1, *2, *3, an exception in *e

cljs.user=> (require-macros 'poppea)
WARNING: poppea$macros is a single segment namespace at line 1 poppea.clj
WARNING: cljs.core/bit-or, all arguments must be numbers, got [string number] instead. at line 121 cljs/tools/reader/edn.cljs
WARNING: cljs.core/bit-or, all arguments must be numbers, got [string number] instead. at line 121 cljs/tools/reader/edn.cljs
WARNING: cljs.core/bit-or, all arguments must be numbers, got [string number] instead. at line 122 cljs/tools/reader/edn.cljs
WARNING: cljs.core/bit-or, all arguments must be numbers, got [string number] instead. at line 122 cljs/tools/reader/edn.cljs
No such macros namespace: cljs.tools.reader.edn, could not locate cljs/tools/reader/edn.clj or cljs/tools/reader/edn.cljc in file cljs/tools/reader/edn.cljs
cljs.user=>

viebel05:07:12

Self-host compatible version of poppea is in github but not deployed yet in clojars

viebel05:07:09

@ericnormand @anmonteiro But you can take it from here - [viebel/poppea "0.2.1"]

viebel05:07:51

I just asked the maintainer of poppea to deploy it to his clojars https://github.com/JulianBirch/poppea/issues/4

anmonteiro05:07:43

@viebel please read above. we were using that exact version

anmonteiro05:07:02

the problem is poppea$macros can’t require a .cljs file

anmonteiro05:07:10

because at that point you’re in a macros env

viebel05:07:01

@anmonteiro in my local setup it works

➜  cache-cljs git:(master) ✗ lumo -k . -c $cp
Lumo 1.5.0
ClojureScript 1.9.542
Node.js v7.10.0
 Docs: (doc function-name-here)
       (find-doc "part-of-name-here")
 Source: (source function-name-here)
 Exit: Control+D or :cljs/quit or exit

cljs.user=> (require-macros 'poppea)
nil
cljs.user=>

anmonteiro05:07:39

try upgrading to Lumo 1.6 and deleting the cache

anmonteiro05:07:58

I wonder if I was doing something wrong

anmonteiro05:07:13

what’s your $cp?

viebel05:07:27

When I remove the cache, I get lots of warning but noe error

anmonteiro05:07:06

I wonder if something changed between Lumo 1.5 and 1.6

anmonteiro05:07:08

let me clone the repo

viebel05:07:18

I think that the version of Lumo I’m using is the one you sent me

viebel05:07:28

here on slack

anmonteiro05:07:36

what did that version have that’s special?

viebel05:07:37

I think you sent me the binaries

viebel05:07:04

It contains the fix of the foreign-libs stuff

anmonteiro05:07:30

I get an error in 1.6

anmonteiro05:07:47

just cloned the repo

anmonteiro05:07:52

Planck reports the same error

pesterhazy10:07:56

How nice that reagent 0.7.0 now works in lumo

pesterhazy10:07:04

I don't suppose you can include cljsjs packages like https://github.com/cljsjs/packages/tree/master/react-select ?

richiardiandrea12:07:51

That is super great

richiardiandrea12:07:57

@pesterhazy I think lumo can now resolve jars with -d

dominicm12:07:17

@richiardiandrea you mean resolve maven coordinates to jars?

richiardiandrea12:07:59

if i understood the question up yes :smile:

richiardiandrea12:07:11

actually rereading now, it seems like he is asking if lumo works with cljsjs foreign-libs

pesterhazy12:07:35

Yeah, that's right @richiardiandrea

richiardiandrea12:07:20

unfortunately I have never tried with cljsjs, I am always using yarn for those deps

pesterhazy13:07:36

Good point, that might be easier

anmonteiro15:07:50

@pesterhazy you can use foreign libs with Lumo as long as they don't need browser globals

pesterhazy15:07:42

lumo -D cljsjs/react-select:1.0.0-rc.1,reagent:0.7.0,cljsjs/react:15.5.4-0,cljsjs/react-dom:15.5.4-0,cljsjs/create-react-class:15.5.3-0
(require 'cljsjs.react-select)
Could not require cljsjs.react-select
Cannot read property 'source' of null
	 (NO_SOURCE_FILE <embedded>:6189:190)
	 (NO_SOURCE_FILE <embedded>:990:207)
	 (NO_SOURCE_FILE <embedded>:990:220)
	 cljs.core.LazySeq.sval (NO_SOURCE_FILE <embedded>:704:154)
	 cljs.core.LazySeq.cljs$core$ISeqable$_seq$arity$1 (NO_SOURCE_FILE <embedded>:710:255)
	 Object.cljs.core.seq (NO_SOURCE_FILE <embedded>:414:172)
	 cljs.core.Cons.cljs$core$INext$_next$arity$1 (NO_SOURCE_FILE <embedded>:682:335)
	 Object.cljs.core.next (NO_SOURCE_FILE <embedded>:416:416)
	 Function.clojure.string.join.cljs$core$IFn$_invoke$arity$2 (NO_SOURCE_FILE <embedded>:1973:225)
	 Object.lumo.repl.load_foreign_lib (NO_SOURCE_FILE <embedded>:6189:518)

pesterhazy15:07:41

by the way the use case is a bit silly, not sure why I'd want to require react-select in real life

anmonteiro15:07:56

@pesterhazy I broke foreign libs in 1.5

anmonteiro15:07:59

make sure you’re on 1.6

pesterhazy15:07:11

yeah it's 1.6

pesterhazy15:07:57

like I said it's not a big deal, I can't use react components inside node anyway :slightly_smiling_face:

pesterhazy17:07:13

(defn create-http-server [ctx]
  (let [app (un/express)]
    (.listen app 9999)
    (.get app
          "/action"
          (partial handle ctx)
          ;; #(apply handle ctx %&)
          )))

pesterhazy17:07:59

this snippet, which creates an express server, doesn't work - the express server returns a 404

pesterhazy17:07:24

however if I replace (partial handle ctx) with #(apply handle ctx %&), it works

anmonteiro17:07:44

@pesterhazy what if you move listen to below the .get call?

pesterhazy17:07:27

@anmonteiro doesn't make a difference

pesterhazy17:07:44

seems like it's about partial :confused:

pesterhazy17:07:00

(partial handle ctx) and #(apply handle ctx %&) should be completely equivalent, right?

anmonteiro17:07:07

unless there’s some this binding stuff happening behind the scenes

pesterhazy17:07:52

not on my side

pesterhazy17:07:26

javascript, you're being weird!

anmonteiro17:07:10

:disappointed:

pesterhazy17:07:59

(defn create-http-server [ctx]
  (let [app (un/express)]
    (.get app "/action1" #(apply handle ctx %&))
    (.get app "/action2" #(handle ctx %1 %2))
    (.get app "/action3" #(handle ctx %1 %2 %3))
    (.get app "/action4" (fn [x y] (handle ctx x y)))
    (.get app "/action5" (fn [x y & args] (handle ctx x y z args)))
    (.get app "/action6" (partial handle ctx))
    (.get app "/action7" (fn
                           ([x y] (handle ctx x y))
                           ([x y z] (handle ctx x y z))
                           ([x y z & args] (handle ctx x y z args)))) 
    (.get app "/action8" (fn [x y z & args] (handle ctx x y z args)))
    (.listen app 9999)))

pesterhazy17:07:23

the plot thickens.... action1-5 work, but action6-8 don't work

anmonteiro17:07:55

:fn-invoke-direct maybe

anmonteiro17:07:23

wait, no, that’s not on by default

pesterhazy17:07:51

just tried with lumo 1.5.0 and 1.6.0 - same behavior

pesterhazy17:07:51

(.get app "/action9a" (fn
                            ([x y] (handle ctx x y))))
    (.get app "/action9b" (fn
                            ([x y] (handle ctx x y))
                            ([x y z m] (handle ctx x y z m))))

pesterhazy17:07:01

action9a works, action9b breaks

pesterhazy17:07:55

even though neither of the arities in 9b get called

pesterhazy17:07:47

so it must be express looking at the function and somehow deciding it's unworthy

pesterhazy18:07:52

I'm giving up - the expressjs code is too weird to follow

pesterhazy18:07:12

the simple workaround is not to use partial here :slightly_smiling_face:

rauh19:07:55

@pesterhazy My guess is that Express looks at the function length == # of arguments and then does different stuff. The dispatcher in CLJS will have the fixed args + rest-arg. So (.-length (partial #() 1)) is 4.

rauh19:07:01

Would explain why 5 works, but 8 doesn't. Maybe express does something special if it sees 4 argument function as the handler... No clue

pesterhazy19:07:28

That's what I thought too, but didn't find any relevant occurrence of length

pesterhazy19:07:35

@rauh ^^ the express source is somewhat opaque so I didn't manage to trace

pesterhazy19:07:54

Maybe I'll try with a debugger

pesterhazy19:07:48

Oh that looks relevant

rauh19:07:08

Goes without saying... This is terrible programming style (or API design). GCC --for instance-- will remove unused arguments.

pesterhazy19:07:51

I agree, never seen anything like that in cljs

pesterhazy20:07:22

@rauh, just checked it, your suspicion was right. Express gets confused because the partial has length == 4

pesterhazy20:07:39

on a side note, all partials have length 4, except for partials with > 3 partially applied arguments -- those have length 1

pesterhazy20:07:16

more generally, it seems borderline crazy to check fn.length instead of checking whether args are nil

rauh20:07:19

Yeah, but that might change... I'm working on getting central dispatchers into CLJS core, in which case they'd all be length 0.

rauh20:07:51

I agree, it's super dumb. And not even documented really.

pesterhazy20:07:07

right, it's not in docs as far as I can see

pesterhazy20:07:24

I guess the practical conclusion is to watch out for javascript APIs that reflect on functions when using partial

rauh20:07:04

Yeah best to only use single arity non-variadic fns, they compile down to normal JS fns.

pesterhazy20:07:01

ok. thanks for your help!

rauh20:07:09

Haha I could go on rambling about JS/Node ecosystem. But I'll just leave it at "super dumb". :slightly_smiling_face:

richiardiandrea21:07:30

Lol this made my day :grinning: