Fork me on GitHub
#clojure
<
2016-04-29
>
jimmy07:04:15

hi guys, in lein what does :scope do ? I can see that it has something to do with the uberjar action but not sure what exactly what it does .

plexus08:04:57

You're probably asking because of :scope :provided on ClojureScript. This means that ClojureScript doesn't need to be added to the uberjar, because it's only needed for compilation, not at runtime

shreyas.n10:04:35

@hiredman : i did go through the clojure.java.shell docs, my oAugth key is longer than 128 characters or something , and i could not get it working. @telent : making this call worked for me - (shell/sh "/bin/sh" "-c" rest-call " > " "a.json”). Kudos !

janxspirit15:04:11

question about atoms and swap! - what is the safe way to deref the current value of an atom from within swap! ?

fasiha15:04:27

@janxspirit: you mean like this?: (def a (atom 0)) (swap! a #(do (println %) (inc %))) ? Prints 0 and returns 1.

loganmhb15:04:16

@janxspirit: as in @fasiha ’s example, the function you pass to swap! will be passed the value of the atom as its first argument. you should not need to deref it.

cigitia17:04:44

Given a vector [a b c d], what’s the most idiomatic way to get the sequence ([a] [a b] [a b c] [a b c d])?

aengelberg18:04:13

@cigitia: perhaps (rest (reductions conj [] [a b c d]))

thiagofm18:04:44

@cigitia: a bit late, you can also go with a list comprehension (for [i [1 2 3 4] k [[1 2 3 4]]] (vec (take i k))) 😉

aengelberg18:04:56

that also works, it would be quadratic time to build up all the vectors though

aengelberg18:04:24

@thiagofm: also FYI you can do a :let inside a for-loop, e.g. (for [i [1 2 3 4] :let [k [1 2 3 4]]] (vec (take i k))) instead of list comprehension on a one-element sequence

thiagofm18:04:22

@aengelberg: cool! simple_smile Is there a way to set the [1 2 3 4] somewhere to make it more DRY?

aengelberg18:04:32

note cigitia actually said [a b c d] so we aren't really repeating much if we use that instead of [1 2 3 4]

bassam.khouri18:04:39

Hi. Is anyone familiar with the nREPL library (https://github.com/clojure/tools.nrepl)? If so, please message me offline as I have a question.

fasiha19:04:06

@bassam.khouri: what's the question? Lots of people have probably used nrepl, and chances are much higher of getting an answer if you ask it here instead of asking people to do something before finding out if they can help you…

bassam.khouri19:04:19

@fasiha: I'm using nREPL as a client. My server is returning a typed response. So my client code is throwing a RuntimeException No reader function for tag object clojure.lang.LispReader$CtorReader.readTagged (LispReader.java:1245) How can I ensure nREPL handles the typed return properly?

bassam.khouri19:04:36

and as an FYI.. i'm a clojure newbie!!

bassam.khouri19:04:42

also, when I send a command, which returns a string, to a repl server, nREPL returns a vector with a single item "a string" too. I'm not sure what's happening there..

fasiha19:04:24

@bassam.khouri: a question: are you writing your own nrepl client, or are you using one (like lein repl :connect localhost 7600)?

bassam.khouri19:04:03

I'm writing my own using the nREPL library here: https://github.com/clojure/tools.nrepl

hiredman19:04:14

if you are serializing to tagged readers, your clients reader needs to be able to read them, either by knowing about the same set of tagged readers, or uh, I think is a mechanism to setup a default fallback for unknown tags

hiredman19:04:59

if you are using the reader from clojure.edn the should be something similar

bassam.khouri19:04:03

@hiredman: does this mean I need to make sure my project can read the data being returned? if so, does that mean I need to pull in a dependency?

risto19:04:09

What does the ! mean in some variable in clojure? like swap! and set!, is it used to denote an impure function?

risto19:04:57

and if so, is it stylistally correct to denote any functions that's using these impure functions the same way? ie (defn swapit! .... (swap! ...))

manutter5119:04:11

It’s a convention, the language doesn’t enforce it in any way

risto19:04:20

is that what it means though?

manutter5119:04:42

right, it’s a fn that alters state in some way (has side effects, is impure, etc)

thug.nasty19:04:59

does it imply strictness?

manutter5120:04:53

strictness in what sense?

thug.nasty20:04:17

nevermind, I’m used to seeing the ! in Haskell

thug.nasty20:04:35

to meaning strict evaluation

manutter5120:04:21

Heh, my Haskell-fu is too weak, time to dig out my electronic copy of LYAHFGG

ddellacosta20:04:36

oh yeah, thug.nasty it’s a lisp-ism I believe, and I think I’ve seen it in Ruby too

ddellacosta20:04:49

it doesn’t force evaluation like ! in Haskell

ddellacosta20:04:59

it’s purely a convention

ddellacosta20:04:31

(and I should be clear, it doesn’t have anything to do with strict vs. lazy evalution, Clojure only has one evaluation strategy as far as I know, unless we are talking about sequences)

thug.nasty20:04:50

especially on a friday

ddellacosta21:04:31

[plumatic schema filter] if I want to create a sum type-like schema, i.e. something like A | B | C, does it make more sense to use enum or conditional ? I don’t have any complex predicates so conditional seems like overkill here, but the ‘variant’ example in the wiki docs only talks about using conditional

c0rrzin21:04:00

I think you want cond-pre

ddellacosta21:04:12

I find that example rather confusing honestly

ddellacosta21:04:36

@c0rrzin: why that vs. enum?

ddellacosta21:04:28

hrm, I guess enum is checking value, not type? I’m kind of confused

ddellacosta21:04:26

yeah, I guess that’s it. I wish there was a sum or something but I guess I’m trying to force schema into a type-checking mold

c0rrzin21:04:29

enum is weird for this case, because you’d have many values that conform to the same enum, so this is really not an enum

ddellacosta21:04:36

yeah, I see now

ddellacosta21:04:54

I think what’s confusing me is that it seems like I’m going to end up with something like (s/conditional #(= FooType (type %)) FooType #(= BarType (type %)) BarType), and that seems wrong or at least silly…think I must still be missing something.

ddellacosta21:04:41

I suppose cond-pre shortens it to (s/cond-pre FooType BarType) ?

ddellacosta21:04:51

will give that a shot

nkraft21:04:31

I'm sure my google-fu is just down today, but has anyone here used Selmer to render web templates? What is the syntax for including css and js files? In Python and Django, it's done with the staticfiles setting. Not sure how it works in Selmer.

clem21:04:40

Does anyone have experience with the clj-liquibase library?

seancorfield22:04:32

@nkraft: Since you start with an HTML template with Selmer and use {{..}} to substitute values, just write the appropriate HTML to include CSS/JS files and provide whatever substitution name/value pairs you need in the data hash map you pass to Selmer’s render function.

seancorfield22:04:06

For example, here’s a Selmer template that provides a "layout" around some HTML in the body variable https://github.com/framework-one/fw1-clj/blob/master/examples/usermanager/layouts/default.html

seancorfield22:04:02

And here’s the Selmer template that provides one of the HTML "views" that can be supplied as a body: https://github.com/framework-one/fw1-clj/blob/master/examples/usermanager/views/user/list.html