Fork me on GitHub
#clojure
<
2016-10-02
>
seancorfield00:10:14

@bcbradley Try w/prewalk in your lispify function...

bcbradley00:10:23

i did, it didn't work

seancorfield00:10:36

…ah, but you need to check map-entry? as well

gfredericks00:10:50

oh wow I didn't know that was a function

bcbradley00:10:08

i've got a solution now anyway that is a bit clearer:

(defn lispify-hiccup [[keyword tags & children]]
  (let [foo (symbol "html.core" (name keyword))]
    (if (string? (first children))
      (list foo tags (first children))
      (apply list foo tags (clojure.core/map lispify-hiccup children)))))

seancorfield00:10:09

(defn lispify [s]
  (w/prewalk (fn [e] (if (and (vector? e) (not (map-entry? e))) (apply list e) e)) s))

seancorfield00:10:08

prewalk preserves the MapEntry type, postwalk does not

seancorfield00:10:34

To me, that feels like a bug.

bcbradley02:10:49

how do i put my gpg key on clojars?

tcrawley02:10:50

@bcbradley: you don't, since clojars no longer uses gpg keys

bcbradley03:10:58

how do i deploy to clojars with lein without gpg

bcbradley03:10:17

when i run the file it says "Need to sign 2 files with GPG"

tcrawley03:10:46

that's local, not from clojars - lein is trying to sign your deploy. take a look at https://github.com/technomancy/leiningen/blob/master/doc/GPG.md

bcbradley03:10:20

i don't want to sign it

bcbradley03:10:33

its public domain

gordon04:10:56

>>> To disable signing of releases, set :sign-releases to false in the :repositories entry you are targeting. If you do this, everyone who is depending on your library will not be able to confirm that the copy they get has not been tampered with, so this is not recommended.

seancorfield05:10:23

FWIW @bcbradley Using Boot makes this process easier since you can push to Clojars without any of the GPG baggage that Leiningen still has.

mpenet10:10:17

@bcbradley afaik clojars signing is not about encrypting jars, it s just a way to provide a way to confirm its origin

bcbradley13:10:26

what does clojure.lang.ExceptionInfo: Could not find artifact org.clojure:clojure:jar:1.8.0 in http://clojars.org mean?

bcbradley13:10:56

here is my build.boot:

(set-env!
  :source-paths #{"src"}
  :dependencies '[[org.clojure/clojure "1.8.0"]]
  :repositories [["" {:url ""}]])
(task-options!
  pom {:project 'html
       :version "1.0.0"
       :description "Tools for writing html as clojure"
       :url ""
       :scm {:url ""}
       :license {"MIT" ""}})

bcbradley13:10:00

I'm using boot build-jar push-release

bcbradley13:10:06

am i doing something wrong?

bcbradley13:10:07

I've set up profile.boot in ~/.boot/

bcbradley13:10:22

for my password and username to clojars

tcrawley13:10:49

@bcbradley: clojure itself is hosted in maven central, not clojars. Your :repository entry is replacing the default list of repos. so maven central is no longer in the list

tcrawley13:10:51

you don't need to specify repos unless you need one not in the default list, and clojars is in that list

bcbradley13:10:32

I also figured out that build-jar and push-release come from adzerk, so i have to :dependencies '[[adzerk/bootlaces "0.1.13"]]

bcbradley13:10:23

but now I'm getting a different error, it writes pom.xml and pom.properties, writes the jar, installs the jar and says CLOJARS_USER and CLOJARS_PASS were not set; please enter your Clojars credentials

bcbradley13:10:32

it lets me enter my username

bcbradley13:10:42

but then i get an exception as soon as the password prompt comes up

bcbradley13:10:53

A null pointer exception

bcbradley13:10:48

it says it comes from line 52 here

tcrawley13:10:54

dunno, maybe try asking in #boot

bcbradley13:10:27

Thanks I will! Sorry for being off topic 😞

tcrawley13:10:51

no problem!

bcbradley14:10:12

hey i just pushed a library to clojars and to github, but i'm new to all this

bcbradley14:10:48

how would I require this project in a different one?

tcrawley14:10:27

@bcbradley: you would put [html "1.0.1"] in the :dependencies vector of the other other project

bcbradley15:10:05

i did that in nightcode but i'm getting a long list of errors on teh console

bcbradley15:10:53

says "could not locate html/core__init.class or html/core.clj on classpath."

bcbradley15:10:57

i think it might be my :require in ns

reefersleep16:10:39

That's called destructuring. Google it - your first results will likely be good guides (that I've referred to time and time again : ) @hejcz

hejcz16:10:58

I was reading some random tutorials about destructuring. Just couldn't find this particular example explanation. However you're right it's even on the http://clojure.org

dzannotti16:10:58

@hejcz which part is hard to read/understand? (the destructuring, or the usage of :keys)?

bcbradley16:10:32

woot finally got my first library to work

hejcz16:10:20

I just couldn't find example of destructuring list with :keys

dzannotti16:10:31

oh ok so (list :a 2 5 3 :b 8 2 3) returns (as expected a list of (:a 2 5 3 :b 8 2 3) (note that :a and 😛 are just keywords)

hejcz16:10:24

@dzannotti thanks! I was just trying to find a proof that destructuring list like a map is not somehting wrong 🙂

yury.solovyov17:10:12

what's idiomatic way to do count-by operation? I've done with reduce + case, and it looks pretty long https://gist.github.com/YurySolovyov/7fd36108ae365a9defa145b9fa519b7f

gfredericks17:10:50

e.g., (->> items (map :type) frequencies)

yury.solovyov18:10:00

Works, amazing

lvh19:10:59

Are array-maps like alists in that there ordering property is guaranteed?

lvh19:10:38

I need an ordered-map; I currently use flatland, but that’s essentially unmaintained (I’ve submitted PRs that have fixed bugs that got review but haven’t been merged after >>1mo), so if I can remove a dependency I’ll be pretty happy

gfredericks19:10:24

array-maps are impl details

gfredericks19:10:45

I don't know why array-map is a function

gfredericks19:10:05

if it's not small it will turn into a hash-map as soon as you modify it

gfredericks19:10:15

so not useful for most ordering purposes

lvh19:10:25

too bad; it’d be nice if ordered was easier to use

lvh19:10:55

that definitely explains my hesitation even though I couldn’t get it to not be ordered on the repl; I didn’t realize that it autopromoted

pesterhazy19:10:40

@lvh, there's a fork (?) that adds cljs support and may be more actively maintained: https://github.com/frankiesardo/linked

lvh19:10:22

oh, that’s nice 🙂 Thanks!

lvh19:10:32

I should port my tests to them to make sure they work there too just in case

pesterhazy19:10:58

An ordered map is such a useful data structure

pesterhazy19:10:17

Also the one thing that php got right :)

lvh19:10:52

In my case it’s either have an ordered data structure or reimplement toposort

lvh19:10:57

(I don’t want to reimplement toposort)

gfredericks19:10:32

@lvh are you doing lookups by key?

lvh19:10:33

(are you thinking a seq of pairs?)

gfredericks19:10:26

eeh, something like that I guess

Frank Henard20:10:28

Can anyone make any recommendations of things to study for someone who wants to get a job doing Clojure? This hypothetical person has a strong background in OO programming, but is just ok at functional concepts as well as just ok at Clojure? I have a friend...

dzannotti20:10:30

@ballpark http://www.braveclojure.com/clojure-for-the-brave-and-true/ helped me the most (once i read and understood that, i was able to dig into other books about clojure that i couldn't understand to start with), i think that coming from OO the biggest block it's the mind shift required, and dealing with the frustration of "i already know how to do X in 10 imperative languages"

Frank Henard20:10:59

@dzannotti Thanks for the suggestion. I just bought it!

Frank Henard20:10:35

^ I bought it thanks to your suggestion

dzannotti20:10:18

fwiw i don't think that clojure is a language that you can pick up in a week or so (like switching between imperative languages), takes a much longer time, but eventually you'll never want to go back to anything else 🙂

dzannotti20:10:01

and by you, i meant anyone with a lenghty experience in OO, not you personally of course

seancorfield20:10:17

@ballpark Given "your friend" has a background in OOP, after reading Brave and True as an introduction, move on to Clojure Programming by Emerick et al (on O’Reilly) and then maybe Clojure Applied

seancorfield20:10:28

Above all, consider that you^H^H^Hthey will have to let go of pretty much everything they’ve learned about OOP: no assignments, no loop with indexes, no mutable iterators, no mutable state, essentially letting go of data encapsulation, and relearning polymorphism. That shift is what is the hardest for most OOP folks. But it’s definitely worth it.

Frank Henard21:10:33

Thanks seancorfield and dzannotti!

grzm21:10:05

{ } <- my data encapsulation

hlolli21:10:27

is there a way to tell clojure from which file a function/macro is being evaluated? I know you can find it with meta, but as soon as I evaluate that function from other namespace (other file) I cant seem to find a way to get the filename from the calling file. I think maybe some macroexpansion would do the trick here?

hlolli21:10:19

ah nevermind, what Im doing is so hacky anyway that I just use the last thing after a dot in (ns-name *ns*) and add .clj (in order to resolve buffer name in emacs).