Fork me on GitHub
#clojure
<
2016-05-19
>
josh.freckleton01:05:51

I have a monad question here: https://clojurians.slack.com/files/josh.freckleton/F1A38K75X/random_numbers_in_monad.clj Basically, how can I map a monadic function over a list, or get a sequence of monadic values?

nathansmutz02:05:54

I accidentally created a #C1A38UB5X channel. Does anybody here have the permissions to delete it?

nathansmutz02:05:33

I cant find find any controls to do it myself

danielcompton03:05:19

@josh.freckleton: have you looked at https://github.com/funcool/cats and the other funcool related projects?

josh.freckleton04:05:37

@danielcompton: thanks for the recommendation, playing around with it now. Still though, how can I get a list of monadic values, like what I'm going for in this code?: https://clojurians.slack.com/files/josh.freckleton/F1A38K75X/random_numbers_in_monad.clj

danielcompton04:05:56

sorry, not sure, haven’t ever used it, just know it exists

josh.freckleton05:05:27

@danielcompton: I'm having fun tinkering with it, thanks, it's a different take than algo.monads. It should still be simple, I imagine, to do what I'm trying though. hmm....

m1dnight09:05:46

You can’t/shouldn’t. A monadic function produces a monadic value and a list of monadic values is not a monadic value per se.

m1dnight09:05:18

You could use this.

m1dnight09:05:38

That will produce a monad list of numbers, not a list of monadic numbers.

m1dnight09:05:41

If that makes sense.

m1dnight09:05:56

Disclaimer: I’m a haskeller and have only played a bit with Clojure monads.

jonas13:05:28

In clojure.java.jdbc, is there a way to globally change the default {:identifiers str/lower-case} to {:identifiers identity}. It's kind of annoying when you explicitly in SQL do select my_column as "myColumn" ... and clojure.java.jdbc insists on turning it into "mycolumn". Especially when using hugsql (or yesql).

squiter13:05:08

Hey guys, I'm new in clojure, and I have a doubt. I've seen a lot of examples using match from this lib: https://github.com/brool/clojure-misc and I want to know if that lib is popular.

squiter13:05:36

I'm from ruby, and in ruby we have the http://rubytoolbox.com where I can see if a lib is popular or not

squiter13:05:00

do we have a place where i can find that for clojure?

roberto13:05:10

I’m not familiar with ruby, but maybe https://clojars.org/ could be helpful

squiter13:05:28

Nice tip @roberto, thanks! The clojars have a donwnload number! It will work

roberto13:05:45

I don’t think that displays download numbers

squiter13:05:48

ahhh man! It's so obvious! Sorry to answer haha

squiter13:05:16

yeah, they dont have any number to compare popularity

roberto13:05:52

some links are also dead

roberto13:05:57

I clicked on Joodo

borkdude13:05:15

There was a website where you could see how popular a dependency was. Can't remember it

borkdude13:05:21

Grimoire maybe?

donaldball13:05:36

You could maybe infer from cross-clj, but its coverage is somewhat spotty

borkdude13:05:51

yeah, maybe it was that one

donaldball13:05:00

On the specific question, I think most would prefer core.match

maxim13:05:06

It would very good to have something similar to ruby-toolbox. For beginners and others. Now you need to do a lot of manual work. I wonder why it still doesn't exist.

roberto13:05:11

isn’t grimoire just documentation?

borkdude13:05:03

yes, I guess so, I always forget which is which

squiter13:05:22

the most referenced projects section in https://crossclj.info/ its awesome 🙂

squiter13:05:13

@donaldball: thanks for the answer! I was looking for a alternative to do pattern matching like haskell

squiter13:05:38

core.match its an awesome alternative

agi_underground14:05:56

hi, maybe here someone can help me? How to start jetty with HTTP2 if my app needs a param(port)? I use clojure. I try this command: java -Dport=4334 -Dadd-to-start=http2 -jar target/app-0.1.0-SNAPSHOT-standalone.jar But it's doesn`t work. My main function is: (defn -main [& [port]] (let [port (Integer. (or port (env :port) 5000))] (run-jetty (site #'app) {:port port :join? false})))

roberto14:05:21

I think those are system properties, to read those you would need to do (System/getProperty “port”)

josh.freckleton15:05:38

@m1dnight: hm, I'm aware that [mv] is different from mv. But say I really want a list of mv, such as in this example where I want a list of random numbers. How can I achieve that with a monad? https://clojurians.slack.com/files/josh.freckleton/F1A38K75X/random_numbers_in_monad.clj

josh.freckleton15:05:59

(I can't quite figure out m-map yet)

josh.freckleton15:05:09

nm, you put me on the right path, and m-seq seems to help: ((m-seq (take 10 (repeatedly randy))) [4 5])

Petrus Theron15:05:37

Can I pass an argument to test functions from my (use-fixtures :each (fn [f] … (f some-arg)) fixture using clojure.test?

Petrus Theron15:05:11

Or do I have to use binding / with-redefs?

pesterhazy15:05:07

Is there a way to introspect (using reflection) the ctor's of a class?

pesterhazy15:05:44

I'm using a Google API with sadly lacking documentation.

borkdude15:05:23

@pesterhazy: maybe the constructor is private and you're not supposed to call it?

pesterhazy15:05:01

@borkdude: quite possible, but there must be some factory or whatever to create an instance of this

borkdude15:05:18

@pesterhazy: it's not open source?

pesterhazy15:05:26

good point, I should check. I just got it from maven

pesterhazy15:05:54

I actually found the javadoc 🙂

scriptor18:05:58

is there a way to get a list of all the signatures of a given protocol?

andmed18:05:52

Hi. Is there any way to reload a java class in IDEA Cursive REPL?

jr19:05:35

user=> (Long/MAX_VALUE)
9223372036854775807
user=> Long/MAX_VALUE
9223372036854775807

jr19:05:53

how are both of those forms valid?

bronsa19:05:04

the former is old syntax

jr19:05:52

ah and expected to be deprecated?

bronsa19:05:00

don't think it will, but don't use it

hiredman19:05:23

the (Class/staticMethod arg1 arg2) syntax is sugar over the dot special form (. Class staticMethod arg1 arg2), the dot special form can also access static fields like (. Class staticField), and the same transformation generates valid dot forms for both

hiredman19:05:44

the field case may even have been an accident when the slash form sugar was added

jr19:05:35

perfecto. Thanks for the explanation

jr19:05:17

(. Class staticField) explains my confusion

agi_underground20:05:45

Hi, this is i am again. My problem is how to enable http2 to my project, that use jetty server. I think i can not add param --add-to-startd=http2 becouse my project use jetty like internal entity, i have defined dependency in project.clj, and in this way, my project use already compiled jar file from .m2/repository/org/eclipse/jetty/jetty-server/9.3.8.v20160314 and becouse this i can not set my own params to enable http2. Maybe someone already configured jetty to use http2 in projects? How i can do this?

mj_langford20:05:50

Any good tips on Could not locate hello__init.class or hello.clj on classpath. Exception in thread "main" java.io.FileNotFoundException: Could not locate hello__init.class or hello.clj on classpath., compiling:(/private/var/folders/bm/lpyn0q012k91nr2311jtk1gh0000gn/T/form-init8179222076077936243.clj:1:125) ? lein uberjar and I are making an acquaintance today and she’s spitting in my eye

jswart20:05:21

The path to your source files is probably wrong. I use boot, and haven’t touched lein in a long time so I can’t point you to it exactly but I think it was “source-paths” or something like that.

jswart20:05:27

That is where I woudl start looking.

jswart20:05:42

Another thing is if you have incorrectly aligned your namespace to your file paths, which includes what I already mentioned.

hiredman20:05:15

also that error indicates a single segment namespace name, which you shouldn't use

mj_langford20:05:31

I was attempting to use a tutorial as written

mj_langford20:05:43

(amazon lambda with clojure)

hiredman20:05:23

if a tutorial is telling you to use a single segment namespace, I would guess it is written by someone who doesn't know clojure, so following it verbatim may not be the best

mj_langford20:05:38

as he also wrote a scala program, you might be onto something

agi_underground20:05:46

5900 members of group, defenetly someone use http2 with jetty, hey where you are?

roberto20:05:21

sorry, i’ve never used http2

mj_langford20:05:41

ty hiredman, that was an entirely good example of what was wrong, wrong source paths + single segment namespace

mj_langford20:05:46

I’m completely set

m1dnight22:05:42

Is there something in Clojure that would easily let me map vectors (e.g. [“foo” 1]) onto values of an arbitrary type?

m1dnight22:05:56

Something like a dictionary where vectors are the key.

m1dnight22:05:58

Oh, assoc seems to be what I was looking for! 🙂

danburton22:05:13

Yes, clojure maps can use any type as the key. {["foo" 1] "one foo"} is a perfectly valid map.