Fork me on GitHub
#clojure
<
2017-07-10
>
hiredman00:07:07

thats not what I meant

hiredman00:07:10

a bidi route is sort of two parts, the routes(the left hand side) which are like a pattern that the url is checked against, and then the handlers (the right hand side) which are returned if the route matches

hiredman00:07:00

ResourcesMaybe is a handler, so by the time it is running, routing is "done". Routing ran, determined that ResourcesMaybe is the handler to use

hiredman00:07:47

what you want to do is move the resource existence checking from the right hand side (the handlers) to the left hand side (the routes), so existence of the resource is checked for while routing, not after routing

hiredman00:07:25

but all that being said, the way I usually solve this problem is by not having it, I put all static resources under a prefix that no other routes start with, so if ResourcesMaybe fails then there isn't anything else to route to

seancorfield02:07:02

@cjhowe Took me a while, experimenting and searching on Bing, but I think this will help you http://grokbase.com/p/gg/clojure/151d2ffehq/equivalent-of-compojure-resources-in-juxt-bidi

cjhowe03:07:49

@seancorfield seems like exactly what i need, thanks!

shidima_08:07:32

Not sure if I should ask here, i'm using Intellij with cursive, but it seems to be unable to resolve some of my code (like (db/add-message). I have been watching a video by @yogthos and it seems he has the same problem in the screen cast. So I'm assuming it is normal?

cfleming09:07:32

@shidima_ There’s a #cursive channel, probably best to ask over there.

octahedrion12:07:50

is there a spec for spec ?

mpenet12:07:52

@octo221 there's a jira for spec for spec

benbot14:07:51

Hey I’m pretty new to clojure and the whole java ecosystem and I’m having some issues using this slack clojar. It’s been telling me that it can’t locate clj_slack__init.class or clj_slack.clj on the classpath. I declared the dep in my project.clj file and I checked that it was installed with lein deps :tree… so at this point I’m lost

a1314:07:43

who's been telling you and who can't locate? 🙂 Also: #beginners

benbot14:07:06

:0 I didn’t even know that existed. thanks

benbot14:07:19

and lein run and… java I think

benbot14:07:17

(ns thing.core
  (:gen-class))

(require 'clj-slack)

a1314:07:27

require should be :require inside ns declaration

benbot14:07:56

same issue

bfabry14:07:07

@benbot the clj-slack library does not seem to have a namespace clj-slack, so you can't require it

bfabry14:07:16

I see clj-slack.users etc

yvon15:07:43

I would like to create a registration form with

ClojureScript
using
React-Native
(and
Reagent
thereafter). And I would like to include the different components with MaterialDesign, and I do not know how to do it. Do you have any suggestions? I have already found on the Internet, but I did not have much. I just want to create a simple registration form, using ClojureScript MaterialDesign ReactNative.

yvon15:07:28

Thanks in advance for your feedback.

yvon15:07:16

Name

Your Name
Email
Your Email
Password
Enter your password
Send Cancel

plins18:07:53

hello everyone, im trying to figure out uncessary dependencies on my project (im using lein) searching the webs ive found lein deps :tree but its output is quite large and im not sure where exactly to look

plins18:07:04

does anyone has any suggestion?

bfabry18:07:15

so I have a project, which has :aot :all in the :uberjar profile (in this scenario compiling at runtime was significant, trust me, I measured) but I'd prefer not to have that accidentally interfere with dev if a dev creates an uberjar on their machine. is there any way to either have leiningen delete the .class files after the uberjar is created, or exclude target/classes from the classpath?

michaelblume18:07:00

I’m a little bit confused — ^bytes is supposed to be a valid type hint and I’m supposed to be able to type hint the return value of a function by hinting the function name, right?

michaelblume18:07:56

(defn ^bytes foo-bytes []
  (.getBytes "foo"))

(defn foo-string []
  (String. (foo-bytes)))

bfabry18:07:01

@michaelblume I didn't know ^bytes was a valid type hint. I've been using ^"[B"

michaelblume18:07:05

I get an error

michaelblume18:07:17

I can use it on arguments and it works fine

michaelblume18:07:44

(defn string-from-bytes [^bytes b]
  (String. b))

michaelblume18:07:47

gives me no problem

michaelblume18:07:59

it seems odd that I can use it to hint arguments but not return type

bronsa18:07:45

@michaelblume don't type hint the var name

michaelblume18:07:46

maybe create an alias that creates an uberjar outside the target folder, then runs lein clean?

bronsa18:07:50

type hint the argvec

michaelblume18:07:42

@bronsa cool, thanks, that works

michaelblume18:07:47

how come type-hinting the name sometimes works?

bronsa18:07:00

type hints on the var name don't work in case of primitive/"special" type hints

bronsa18:07:03

because they get resolved

bronsa18:07:15

so you're type hinting using the bytes function rather than the bytes type

bronsa18:07:45

there's a number of other pitfails when you type hint no the var name

bronsa18:07:57

everything that you acn express by type hinting on the var name you can express by type hinting on the argvec, and more

bronsa18:07:07

so I always suggest to only type hint on the argvec

bronsa18:07:23

and avoid having to know about the edge cases

michaelblume18:07:29

…would it make sense to print a deprecation warning when type hinting the var-name for a release or two, and then disallow it?

Alex Miller (Clojure team)18:07:37

var meta is resolved, meta on args and argvec is not and the “special” hints can be used in those locations

Alex Miller (Clojure team)18:07:05

we have no plans to stop allowing meta on vars

bfabry18:07:10

ah, so type hinting the return with ^"[B" would work?

Alex Miller (Clojure team)18:07:10

as it would break existing code

bronsa18:07:36

but again, there are other issues when you're typehinting on the var name

bronsa18:07:50

like, type hinting primitive hints won't cause the funcntion return type to be optimized

bronsa18:07:56

if you type hint the argvec it will

michaelblume18:07:14

huh, ok, I’ll try to remember to do that =)

bronsa18:07:36

I think eastwood might complain about bad type hints

michaelblume18:07:00

huh, ok, I’ll check if it complains about hinting the var name, if it doesn’t it probably should

bronsa18:07:30

it might complain about bad type hints, not about all hints on var names

bronsa18:07:45

can't remember

bronsa18:07:49

it's been a while

michaelblume18:07:18

@bfabry did you see my aliasing suggestion? would that work for you?

madstap18:07:50

@plins You should check out https://github.com/walmartlabs/vizdeps It draws a graph of the info found in lein deps :tree.

bfabry18:07:01

@michaelblume it would work, but looking for a solution that won't require me to change anything other than the leiningen project.clj. getting an alias rolled out to all devs, all deploy boxes etc is a chore

michaelblume18:07:35

oh, you can have aliases in project.clj

bfabry18:07:40

@plins as sad as it is, I'm not actually sure all the information required to know whether a dependency is used or not exists statically

bfabry19:07:45

I think I actually just need to understand :target-path and :compile-path a bit better and I can make this work

lwhorton19:07:15

this isnt really a clojure specific question, but I’m curious to hear how to handle it idiomatically (if one exists) in clj. how does one evolve data (domain entities in an application) over time with minimal changes and minimal complexity? https://groups.google.com/forum/#!topic/clojure/hA0so8Fp8lg

bfabry19:07:18

namespaced keys and addition over destruction 😛

noisesmith19:07:45

also - generally keep your data as flat as possible

bfabry19:07:50

^ oh yeah and that

lwhorton19:07:09

just keep accreting the changes, leaving the old keys there?

bfabry19:07:38

finicky nested over "organized" data models are magnets for repeated restructures into a new "better, more organized" structure

noisesmith19:07:52

you can deprecate keys - move them from required to allowed but not mandatory

hcarvalhoaves19:07:58

@noisesmith any arbitrary nested object can be seen flat w/ namespaced keys, so things go hand in hand

lwhorton19:07:13

more specifically, say I have some client entity

{:thing ""
:schedule {:start "" :end ""}
are you saying instead to
{:thing ""
:schedule/start ""
:schedule/end ""}

noisesmith19:07:46

@hcarvalhoaves right - it’s not an absolute but a tendency - and I would discourage using namespaces as if they were a series of nested keys…

lwhorton19:07:48

then maybe evolving end to “completed” would equal {:thing "" :schedule/start "" :schedule/end "" :schedule/completed}?

bfabry19:07:17

@hcarvalhoaves what about (s/def ::tree-node (s/keys :req [::left ::right]))

lwhorton19:07:37

or perhaps more appropriately {:thing "" :schedule_start "" :schedule_end "" :schedule_completed}

lwhorton19:07:55

to avoid namespaces being a series of nested keys

lwhorton19:07:09

but at some point code that renders a view by looking at an entity’s (get-in x [:schedule :start]), or in a better organized entity (:schedule_start x) would have to be changed either way, no?

hcarvalhoaves19:07:53

(:schedule/start x)

hcarvalhoaves19:07:00

@bfabry by "nested" I'm thinking document-oriented representation. this tree-node definition is more like a memory model (you're describing the shape of a tree vs. a tree that represents anything in particular - e.g. company org chart)

madstap19:07:34

@noisesmith Can you elaborate on what you mean by "using namespaces as if they were a series of nested keys"

alricu19:07:58

Hi all, I am trying to get the value of a key from a hashmap in clojure but I am getting always nil.

noisesmith19:07:18

@madstap replacing {:foo {:bar {:baz 0}}} with {:foo.bar/baz 0} where there is no foo.bar ns in your app

noisesmith19:07:49

@alricu can you show how you put the value in and how you get it out?

alricu19:07:06

for instance I have something like [{:one "something"}]

alricu19:07:34

I do (:one nameVariable)

noisesmith19:07:56

well, that’s not a hash-map, it’s a vector with a hash-map at index 0

noisesmith19:07:16

in that example (get-in v [0 :one]) would work

alricu19:07:40

sorry I did not realize that!!!

alricu19:07:47

I am new to clojure!!

noisesmith19:07:45

it’s OK - maybe you don’t need the vector part?

alricu19:07:04

actually is the response from a REST service

alricu19:07:12

so I do not have any option!!!

mago19:07:38

you could map or reduce over the collection you receive. (map key coll)

dpsutton19:07:51

Loom (the graph library) has an Edge protocol which has src and dest. But when you call add-edges on a graph it expects the edges in the form [n1 n2]. What's the point of that protocol is i can't easily extend it how I like and instead have to implement nth?

dpsutton20:07:49

:add-edges*
   (fn [g edges]
     (reduce
      (fn [g [n1 n2]]
        (-> g
            (update-in [:nodeset] conj n1 n2)
            (update-in [:adj n1] (fnil conj #{}) n2)
            (update-in [:adj n2] (fnil conj #{}) n1)))
      g edges))

dpsutton20:07:13

(defprotocol Edge
  (src [edge] "Returns the source node of the edge")
  (dest [edge] "Returns the dest node of the edge"))

; Default implementation for vectors
(extend-type #?(:clj clojure.lang.IPersistentVector
                :cljs cljs.core.PersistentVector)
  Edge
  (src [edge] (get edge 0))
  (dest [edge] (get edge 1)))

dpsutton20:07:39

these seem incompatible. Add edge and destructure [n1 n2] so why bother with defining edge on peristent vector as 0 and 1 elements?

roklenarcic20:07:09

The library author coded against his implementation of edges

roklenarcic20:07:36

Which makes the whole thing busted

roklenarcic20:07:50

I am sure you can create a pull request to fix this

dpsutton20:07:39

just making sure I wasn't overlooking anything

tmountain20:07:20

anyone using clojure w/ grpc? I've found a few examples on github, but nothing official looking. trying to find some good boilerplate.

schmee21:07:06

anyone watch Stuarts talk on REPL-driven development? https://vimeo.com/223309989

schmee21:07:32

at 16:55 he talks about “REPL at a point of interest”, anyone know a library that does that?

schmee21:07:05

I’m looking at https://github.com/razum2um/clj-debugger, but when I tried that I got weird error involving java.lang.UnsupportedOperationException: Can't type hint a primitive local

roklenarcic21:07:42

I guess his code is busted

roklenarcic21:07:20

can you publish whole code and stacktrace

schmee22:07:05

here’s the full stack trace:

schmee22:07:36

but yeah hiredman, you’re probably right

hiredman22:07:45

&env will contain symbols with metadata like {:tag 'long} (where long is a primitive type hint) and the compiler will barf with that error message if you use a symbol like that as the name in a binding

hiredman22:07:43

the compiler wants (let [x (long ...)] ....) not (let [^long x ...] ...)

hiredman22:07:07

it bites everyone writing a big macro eventually

michaellindon22:07:17

If I want to create a logo for a clojure library that I have been developing. is there any sort of legal issue if I use the same colourscheme as the clojure logo? That is, I use the 2 green and 2 blue colours to colour my logo?

michaellindon22:07:30

ok cool, thanks

zylox22:07:00

just dont make it a blue c with two green strokes through it and come near kansas city

michaellindon22:07:33

what does t do?

zylox22:07:04

that looks nice

zylox22:07:44

what does t do? sorry what?

michaellindon22:07:21

hehe sorry, i thought Cerner was the name of a clojure library

michaellindon22:07:32

what dose it do?*

michaellindon22:07:40

i just chekced the website

michaellindon22:07:44

do you work for them?

zylox22:07:32

sorry ya its a med tech company

rinaldi23:07:59

Is there a best practice to read/write ZIP files in Clojure? I have found the fs library today and the Java way but unsure what's the recommendation.

hiredman23:07:52

I've only ever used the java.util.zip package