Fork me on GitHub
#clojurescript
<
2015-11-03
>
grav13:11:11

anyone used open layers and externs?

martinklepsch13:11:27

@grav open layers is a closure library, you should be able to use it without externs

grav13:11:29

@martinklepsch: well it doesn’t work in advanced compilation.

martinklepsch13:11:57

@grav: how do you use it?

grav13:11:23

I refer to it as eg js/ol.style.Circle., and it changed my code to something along the lines of new ()

martinklepsch13:11:45

@grav: how did you include it in your project?

grav13:11:49

I have no clojure-specific setting for it, eg. I just load it from ol’s cdn from my index.html

grav13:11:12

<script src="http://openlayers.org/en/v3.10.0/build/ol.js" type="text/javascript"></script>

martinklepsch13:11:31

@grav: also search the issues in this repo for additional discussion

grav14:11:50

@martinklepsch: I tried that, but I may have used in incorrectly. Will try again, and report back simple_smile

martinklepsch14:11:36

@grav there are people using this in production I think. IIRC OL is pretty big so you really want dead code elimination etc. simple_smile

jeremyraines14:11:34

For trying out lein-figwheel 0.5.0-SNAPSHOT, could I do lein new figwheel foo then just change the plugin version? Or do I need to do something prior to generating the project?

jstew14:11:57

changing the plugin version should be good enough, just make sure that if any of the figwheel options have changed, that you change them in project.clj as well.

thheller14:11:38

hmm packaging openlayers via cljsjs seems like a terrible idea, considering it is already closure compatible js

martinklepsch14:11:03

@thheller: it’s packaged as a :lib instead of :foreign-lib

martinklepsch14:11:49

this way you can pull it in via maven in a form that the clojurescript compiler understands without any extra effort on the side of the user

thheller14:11:27

ah though it was using the advanced compiled version that openlayers ships

thheller14:11:32

instead of the full source

martinklepsch14:11:43

no, it’s full closure compatible source

martinklepsch14:11:03

which makes it one of the nicest to use libs in cljsjs I think simple_smile

thheller14:11:20

yeah closure-js is much better integrated than common-js&co

bhauman16:11:55

wow openlayers looks very cool

anmonteiro16:11:18

hey guys, newbie question from a first time submission (http://dev.clojure.org/jira/browse/CLJS-1411)

anmonteiro16:11:29

the wiki says "Edit the ticket's Patch field to indicate either "Code" or "Code and Test". This makes it easier for others to find patches in need of review."

anmonteiro16:11:39

I'm not sure what this means?

anmonteiro16:11:09

is there something else I need to do or should I just wait ..?

dnolen16:11:33

@anmonteiro: there’s a #C07UQ678E channel

anmonteiro16:11:27

did not know that

settinghead16:11:29

is there a way to use your own macro with cljs-bootstrap-compiled code? say

(defmacro unless [pred a b]
  `(if (not ~pred) ~a ~b))

(unless false (println "Will print") (println "Will not print"))

settinghead17:11:57

the code above compiles into the following:

cljs.user.unless = (function cljs$user$unless(_AMPERSAND_form,_AMPERSAND_env,pred,a,b){
return cljs.core.sequence.call(null,cljs.core.concat.call(null,cljs.core._conj.call(null,cljs.core.List.EMPTY,new cljs.core.Symbol(null,"if","if",1181717262,null)),cljs.core._conj.call(null,cljs.core.List.EMPTY,cljs.core.sequence.call(null,cljs.core.concat.call(null,cljs.core._conj.call(null,cljs.core.List.EMPTY,new cljs.core.Symbol(null,"not","not",1044554643,null)),cljs.core._conj.call(null,cljs.core.List.EMPTY,pred)))),cljs.core._conj.call(null,cljs.core.List.EMPTY,a),cljs.core._conj.call(null,cljs.core.List.EMPTY,b)));
});

cljs.user.unless.cljs$lang$macro = true;
cljs.user.unless.call(null,false,cljs.core.println.call(null,"Will print"),cljs.core.println.call(null,"Will not print"));
however the execution result is wrong

dnolen17:11:34

@settinghead: the rules about macros are not different between ClojureScript JVM and JS

dnolen17:11:38

it must be in a macro file

mfikes17:11:56

I've been pondering, and I think the self-host macro rule ends up being: “To call a macro, it must be defined in a namespace required as a macro namespace.”

bhauman18:11:48

@richiardiandrea: Hey I fixed the repl-api and I just re-deployed the SNAPSHOT. Make sure you do a lein clean before trying it.

bhauman18:11:20

yeah it was really broken

bhauman18:11:41

easy to tell it's not a code path I use often

bhauman18:11:54

thanks for the heads up on it

jeremyraines18:11:06

I get the same issue still

jeremyraines18:11:20

is there a reason lein clean could not work as expected?

jeremyraines18:11:38

I didn’t see any downloads happen after the lein clean and then running lein figwheel

dnolen18:11:31

@jeremyraines: lein clean only works if you specify :clean-targets

jeremyraines18:11:58

what do I add there to have it clean dependencies?

bhauman18:11:16

@jeremyraines: what platform are you on?

bhauman18:11:36

you should have seen the new SNAPSHOTs download

bhauman18:11:30

you may have to delete the figwheel snapshots manually from your ~/.m2/repository

bhauman18:11:42

and then start figwheel

bhauman18:11:09

I was advising you to run lein clean to get rid of Clojure cached classes

dnolen18:11:19

@jeremyraines: it’s just a vector of file paths

jeremyraines18:11:27

ok, wasn’t sure if it was advisable to have it reach outside the project

jeremyraines18:11:17

removing it from ~/.m2 made the downloads happen, but I get this error

jeremyraines18:11:42

Exception in thread "main" java.lang.RuntimeException: No such var: figwheel-sidecar.repl-api/start-figwheel-from-lein

bhauman18:11:09

yeah you didn't get the new plugin

bhauman18:11:42

make sure you deleted lein-figwheel as well

jeremyraines18:11:09

after that, lein clean lein-figwheel, same error

jeremyraines18:11:01

sorry, forgot to delete the others from m2

jeremyraines18:11:55

is there a way to connect this method with the system stuff yet, for example to get CSS watching?

bhauman19:11:48

@jeremyraines: CSS watching works you have to configure it

bhauman19:11:26

:figwheel-options :css-dirs

richiardiandrea19:11:28

oh it's been changed to figwheel-options

richiardiandrea19:11:19

@bhauman: is it figwheel-options both inside and a cljsbuild and inside lein project?

jannis20:11:08

Is there a more pretty way to map a list of things (e.g. numbers) to a list of maps than (map #(-> {:id %}) [1 2 3 4]), i.e. something more elegant than ->?

ddellacosta20:11:47

jannis, I’d tend to do what you’re doing more explicitly, simply using (map #(hash-map :id %) [1 2 3 4])

dnolen20:11:59

@jannis lots of way for that specific case

christianromney20:11:03

(map (partial hash-map :id) [1 2 3 4])

christianromney20:11:13

depends on your idea of elegance

dnolen20:11:15

(zipmap (repeat :id) [1 2 3 4])

ddellacosta20:11:35

dnolen, that doesn’t work

dnolen20:11:46

oh right sorry

dnolen20:11:51

not one map, N maps

ddellacosta20:11:58

but, similarly you could do (map hash-map (repeat :id) [1 2 3 4])

ddellacosta20:11:13

not sure that’s an improvement or not…haha

jannis20:11:20

Haha, okay

ddellacosta20:11:26

I think Jannis’s original was the shortest actually!

ddellacosta20:11:33

at least, I can’t figure out how to make it more concise

jannis20:11:02

I guess #(-> [:id %]) is fairly obvious and you can see the structure of the resulting maps right in front of your eyes.

christianromney20:11:27

I would recommend whichever formulation “future you” will grok the most readily

dnolen20:11:28

-> is noise in this case

ddellacosta20:11:31

yeah, my only argument against the threading macro is that it’s not really any more clear here

dnolen20:11:00

(map #(hash-map :id %) [1 2 3 4])

ddellacosta20:11:06

christianromney, yeah. simple_smile

ddellacosta20:11:11

(re: future you comment)

christianromney20:11:31

provided you’re not on a team with some collective idioms already established

jannis20:11:40

@christianromney: Yep, good point. @dnolen: That's nice, too.

roberto20:11:46

(map (partial hash-map :id) [1 2 3 4] But maybe a little bit more obscure.

christianromney20:11:52

that’s a case in point. my brain naturally gravitates to partial in these cases even though #() is shorter

roberto20:11:41

yeah, I find partial more explicit, but it requires knowledge of partial. Might be harder for beginners.

christianromney20:11:42

of course it depends on arg position

roberto20:11:48

oh, yeah, that too simple_smile

dnolen20:11:25

personally I never use partial and suspect it’s as verbose as it is to encourage people to just use fn literals

dnolen20:11:46

also if you’re a perf nut depending on the compiler there are implications for partial vs. inline fn literal

dnolen20:11:49

but agreed it’s most a readability / intention thing

Tim20:11:55

when you’re using partial, it doesn’t really make it a partial like it haskell? its more or a hack?

dnolen20:11:17

“doesn’t really make it a partial"

dnolen20:11:20

what does this mean?

Tim20:11:49

like, does partial in clojure have the same power as partial functions in haskell?

dnolen20:11:10

I don’t understand - partial functions don’t have anything to do with haskell

dnolen20:11:16

it’s just a functional programming concept

Tim20:11:40

interesting

Tim20:11:25

so partials in clojure works as any other partial function in other functional languages?

mrg20:11:38

It's a partially applied function, no different from any other function

mrg20:11:53

You can do with it whatever you can do with functions otherwise

ddellacosta20:11:43

haskell’s evaluation strategy is fundamentally different from Clojure’s, being lazy, so you can’t really compare the two tmtwd

Tim20:11:07

interesting

ddellacosta20:11:27

it is analogous to a partially applied function in Haskell I suppose, but you don’t need a special function for it in Haskell

thomasa20:11:36

@tmtwd: I'm not sure if this answers your question, but 'partial' only uncurries the arguments it needs to. You could write code like in haskell but you'd have to put partial in front of every single function!

Tim20:11:27

I’ll have to look into it some more

ddellacosta20:11:17

thomasa, I’m not sure I understand what you mean by “put partial in front of every single function”…are you talking about what you would have to do in Clojure to imitate Haskell’s behavior?

thomasa20:11:39

actually, sorry I don't mean every single function, i mean every fn with more than one argument

lvh21:11:58

jannis: I would probably write that (for [i [1 2 3 4]] {:id i})

jannis21:11:11

@lvh: Not bad either simple_smile

jslavin22:11:21

Anybody know when the next release of clojurescript is going to be released? I am seeing java.lang.NullPointerException at com.google.javascript.jscomp.JSModule.sortInputsByDeps(JSModule.java:263) It appears this is potentially resolved with CLJS-1469 :modules regression

dnolen22:11:41

shooting for this Friday

jslavin22:11:35

excellent, thanks

richiardiandrea22:11:58

@dnolen: wouldn't be awesome to add a layer on top of figwheel with cards and a in-brower repl? Voila' we have a ClojureScript IDE 😄

dnolen22:11:22

@richiardiandrea: I already have a ClojureScript IDE it’s called Cursive 😉

dnolen22:11:42

but yes, something like that would be cool for it’s own reasons

richiardiandrea22:11:35

very cool indeed

bhauman23:11:33

@richiardiandrea: :figwheel-options is not to be used inside the project.clj Its only for calling figwheel-sidecar functions that kick off figwheel