Fork me on GitHub
#beginners
<
2017-10-23
>
eggsyntax00:10:49

@rcustodio I can't recall having seen that particular error, but offhand my guesses are that either 1) you don't have a gen-class in your main ns, and/or 2) that ns doesn't have a fn named -main, and/or 3) you've failed to declare a main class in project.clj . You can find info about all of those at http://www.flyingmachinestudios.com/programming/how-clojure-babies-are-made-lein-run/

eggsyntax00:10:10

(see especially the section How to Build and Run a Clojure Program Without Leiningen)

rcustodio00:10:42

gen-class and aot fits with service to execute -main then, otherwise it not necessary to use gen-class

seancorfield00:10:40

You don't need gen-class/aot. You can specify clojure.main as your :main and then run the uberjar with -m your.namespace and it will run clojure.main's -main and then that will run your.namespace/-main.

rcustodio00:10:34

java -jar XXXX -m core.main?

rcustodio00:10:48

The other thing, i get this message

Warning: specified :main without including it in :aot. 
Implicit AOT of :main will be removed in Leiningen 3.0.0. 
If you only need AOT for your uberjar, consider adding :aot :all into your
:uberjar profile instead.

seancorfield00:10:17

Ignore the warning.

seancorfield00:10:48

(Leiningen has a very fixed view of the world; it's why I switched to Boot!)

seancorfield00:10:45

The comments show the three changes I made (changed :main in project.clj, remove :aot :all from the :uberjar profile there, removed (:gen-class) from ns in quux.core).

rcustodio00:10:05

and its recommended to avoid aot, even in main class?

seancorfield00:10:39

AOT causes a lot of problems, partly because it also compiles transitive dependencies (i.e., more than just your main namespace).

seancorfield00:10:55

Several people will strongly advise against AOT 🙂

seancorfield00:10:23

It's unfortunate that it became the default because that's how Leiningen's templates worked.

rcustodio00:10:51

I see, boot gives more control over it then

seancorfield00:10:53

(and, I think, long ago, there was no -m option to clojure.main perhaps?)

seancorfield00:10:05

Yes, Boot provides much more flexibility.

rcustodio00:10:19

I see, thanks, I will test that later

seancorfield00:10:30

Boot also doesn't force you to deal with GPG like Leiningen (when you get to deploying libraries).

seancorfield00:10:00

Boot also lets you run your newly created app directly:

(! 1221)-> boot -s src call -f quux.core/-main
Hello, World!

rcustodio00:10:45

I see, i will read about boot later.. maybe adapt my apps

rcustodio00:10:56

But for libs lein still “better"?

rcustodio00:10:12

For services, running apps, boot may be a better choice

seancorfield00:10:54

Boot can easily build libraries too.

seancorfield00:10:18

I just ran this in that Leiningen project:

(! 1240)-> boot -d org.clojure/clojure -r src uber jar -m clojure.main target
Adding uberjar entries...
Writing project.jar...
Writing target dir(s)...

Sun Oct 22 17:50:22
(sean)-(jobs:0)-(~/clojure/quux)
(! 1241)-> java -jar target/project.jar -m quux.core
Hello, World!

seancorfield00:10:58

Didn't even need to create a build.boot file (which would just serve to provide defaults for that).

rcustodio01:10:03

I see, thanks

Aron04:10:26

how would someone go around to use bulma in clojurescript?

curlyfry06:10:29

@ashnur I haven't used it myself, but it looks like it's basically just a stylesheet. You should be able to just include it in your index.html (or possibly use :npm-deps to get it from npm).

Aron07:10:50

i am trying, but nothing works. i decided to start over from scratch yet again. just need a coffee break before 🙂

Aron07:10:41

Exception in thread "main" clojure.lang.ExceptionInfo: Call to clojure.core/ns did not conform to spec: In: [2] val: ((require [clojure.pprint :as pp] [clojure.string :as str] [clj-time.core :as time] [clj-time.format :as fmt])) fails at: [:args] predicate: (cat :attr-map (? map?) :clauses :clojure.core.specs.alpha/ns-clauses), Extra input ...

jumar09:10:21

@ashnur share your namespace declaration with us

Aron09:10:52

if i will see that error again 🙂

tdantas09:10:31

hey @seancorfield, what is the problem of AOT transitive dependencies, is related with time/slow to compile ? > AOT causes a lot of problems, partly because it also compiles transitive dependencies (i.e., more than just your main namespace).

tdantas10:10:55

( feel free if you know the answer ( asked to sean because he talked about that and I’m curious about that ^^ )

boldaslove15611:10:37

@wpcarro basically (fn [] false) throws if you pass any args while constantly isn't.

wpcarro17:10:27

@U5WDMBTUJ that was my suspicion. What’s interesting to me is that ((fn [] false) 1 2 3 4) works but (let [func (fn [] false)] (func 1 2 3 4)) does not…

boldaslove15611:10:14

Weird, it throws for me

rcustodio14:10:59

@oliv that is a good question, @seancorfield i would like to know it too

chang15:10:38

@ashnur you should probably send a PR on where you found that one

Aron15:10:24

i closed it already

Aron15:10:17

i just wanted to generate the alphabet using that generator from test.check or how it is called, but it's not as easy as one might wish

noisesmith16:10:52

@oliv @rcustodio if a dependency you use uses AOT, they override your control of all their transitive dependencies, because AOT is contagious and effects all namespaces used by the AOT compiled code. At the time the lib is compiled, (on the provider’s build machine) they decide which version of every lib you will be forced to use.

noisesmith16:10:49

which means you can maybe use one library that does AOT - but using two is pretty much guaranteed to break things unless they take extreme measures to avoid using dependencies directly in their code

mikeyford17:10:14

When using core.matrix, is there a way to populate a matrix in rows when I define it using matrix? Basically, I'm looking to make [[1] [2]] instead of [[1 2]] . I realise I can use (transpose [[1 2]]) for what I'm looking for, but I was wondering if it's possible to define a matrix this way to begin with?

eggsyntax18:10:45

You'll probably get an answer much faster if you post this in #core-matrix . Good luck!

dhruv119:10:57

hey I am trying to use https://github.com/mzabriskie/react-draggable library in my cljs app (pretty new to web dev) the usage instruction on cljsjs tell me to use (js/GlobalName.someFunction) how do i figure out what the global name of the library is? i’ve already tried (reagent/adapt-react-class js/Draggable)

noisesmith19:10:07

@dhruv1 you might get better luck in clojurescript, but based on the Readme I would expect something like (def draggable (js/require "react-draggable")) and then calling methods on draggable after that

dhruv119:10:14

@noisesmith i tried (def draggable (js/require "react-draggable")) and get #object[ReferenceError ReferenceError: require is not defined]

noisesmith19:10:52

what if you add react-draggable to your :require form in your ns declaration, and then use react-draggable after that?

dhruv119:10:16

(ns testing.draggable
  (:require [cljsjs.react-draggable]
            [reagent.core :as reagent])) 

dhruv119:10:33

thta’s what it currently looks like

noisesmith19:10:51

OK - then use cljsjs.react-draggable since that’s what it’s currently named

noisesmith19:10:58

you might want an :as though

dhruv119:10:42

something like this?

(:require [cljsjs.react-draggable :as draggable]
            [reagent.core :as reagent]) 

dhruv119:10:15

thanks. giving it a try

dhruv119:10:05

the required work, but it looks like it’s still undefined

dhruv119:10:13

ex: draggable.blah

dhruv119:10:18

#object[TypeError TypeError: Cannot read property 'blah' of undefined]

noisesmith19:10:42

that would be draggable/blah if it came in via your ns require form I believe

noisesmith19:10:26

things with dots vs. slashes get a little messy in interop, especially on the cljs side because it’s more flexible (and thus it’s easier to form bad intuitions about how it works)

dhruv119:10:17

understood. looks like my environment is messed. trying thisL draggable/blah i now get #object[ReferenceError ReferenceError: cljsjs is not defined]

noisesmith19:10:53

yeah- I’d ask on #clojurescript I’m doing my best to help but not the most qualified at this point 😄

dhruv119:10:21

you’ve been of great help! 🙂 thank you.

dhruv119:10:33

i will follow up on clojurescript. thanks for the help 🙂

Lucas Barbosa21:10:30

Is it ok to use *agent* inside an agent update function to re-enqueue an update on an agent? My agent is a Java ServerSocket, and my update function is basically: accept a client, put it somewhere and repeat. My two thoughts were: a) the described above; b) an infinite loop

alexmiller22:10:38

Seems like that should be fine to me

Lucas Barbosa21:10:07

To shutdown the server, I would enqueue a function that would close the socket

Lucas Barbosa21:10:19

when I say enqueue, I mean send-off

debamitro21:10:01

What’s the most beginner-friendly way to write a desktop GUI app with clojure? Is one of the java frameworks recommended or is there a clojure library for this

Lucas Barbosa21:10:33

is there a loop version of if-let?

taylor23:10:18

maybe for with a :when clause?

noisesmith00:10:50

for is a list-comprehension and not a loop, sadly there is while but that doesn't bind its condition, and there is loop but that doesn't allow you to say "stop recurring when this binding is nil"

noisesmith00:10:19

close is (loop [] (when-let [foo (f)] ... (recur)))