This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-09-14
Channels
- # aleph (1)
- # aws-lambda (10)
- # beginners (161)
- # bitcoin (2)
- # boot (20)
- # cider (3)
- # clara (46)
- # cljs-dev (35)
- # cljsrn (9)
- # clojure (123)
- # clojure-boston (1)
- # clojure-colombia (1)
- # clojure-dusseldorf (3)
- # clojure-gamedev (2)
- # clojure-germany (2)
- # clojure-greece (1)
- # clojure-italy (7)
- # clojure-losangeles (3)
- # clojure-nl (2)
- # clojure-russia (15)
- # clojure-spec (1)
- # clojure-uk (7)
- # clojurescript (75)
- # community-development (5)
- # cursive (5)
- # datomic (25)
- # docs (3)
- # emacs (1)
- # fulcro (11)
- # graphql (131)
- # heroku (1)
- # jobs (1)
- # juxt (55)
- # lein-figwheel (2)
- # luminus (1)
- # off-topic (4)
- # om (8)
- # onyx (32)
- # pedestal (19)
- # re-frame (53)
- # reagent (11)
- # remote-jobs (1)
- # rum (12)
- # shadow-cljs (12)
- # spacemacs (53)
- # testing (2)
- # unrepl (18)
Is there an idiomatic way to get a file-seq
based on a io/resource
for a directory in resources/
in a uberjar?
It works in a lein run/repl session, but when bundled in a jar the file-seq only contains the path to the directory, not the contained subdirectories and files.
you can't get files from inside a jar, you can only get resources, you can make something that acts like file-seq, but file-seq itself isn't an option
I mean, I guess you can unzip the jar and then get a file-seq, but that's not likely what you want
Thanks, I'll dig further how to list files in a resource directory and build something like a resource-seq
np š
Has anybody watched this? https://www.youtube.com/watch?v=nrpsMB2gYI0&index=2&list=PLetHPRQvX4a9iZk-buMQfdxZm72UnP3C9
I know @U04V70XH6 has some thoughts on this and there has been a lot of work recently on updating docs at clojure-docs. For example, I believe the docs for jdbc were updated about a month or two back (http://clojure-doc.org/articles/ecosystem/java_jdbc/home.html)
@U05380FG9 the āsee alsoā section has also been tremendously useful to me as a beginner learning clojure.core
for example yesterday I remembered there was a function to set the value of an atom but forgot its name. I searched for swap!
(which I remember was the function to transform the value of an atom) and looked in see also, which contained reset!
, the function I was looking for
There was a discussion about this on the Clojure mailing list
two key takeaways (imo): 1) docs can be separate from code. No reason to tie doc updates to the main clojure distro. 3rd party docs are welcome! 2) Clojure loves data, can we keep it that way? Why not keep all this documentation in a data format (instead of markdown which is not data, but text). Seems like a combination of clojure core specs, doc strings, comments, and proper formatting could do a lot.
the bits are all there, just needs a bit more editor support
link to the mailing list post: https://groups.google.com/forum/#!topic/clojure/8awHqxldZKA
@U05380FG9 He means that the system of record should be data -- and then all sorts of tools can generate whatever type of docs them want from that data.
I understand the value of consumable/transformable dataā¦ but stillā¦ suppose I want to end up with some documentation that looks like this: https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelector
Most of the main content of that page is straight text and can be represented well as some kind of markup language. How might that be represented with other kinds of data?
I want to help with improving the docsā¦ but Iām honestly having trouble understanding the point being made in the mailing listā¦
Look at http://clojuredocs.org ā http://clojuredocs.org/clojure.core/select-keys ā thatās drawn from data: the metadata of all the namespaces and the functions, and some additional data added from a database, entered as examples by community members.
The only thing on that page drawn from the select-keys
function is the docstring ā and it says Available since 1.0 (from metadata on the function).
Members can contribute to http://clojuredocs.org and members can contribute to http://clojure-doc.org (longer form tutorials and stuff about the ecosystem rather than core Clojure).
In addition to the raw data inherent in the Clojure core code itself (namespaces, symbols, metadata, docstrings), there are also all the core specs which can be used to generate all sorts of additional documentation (folks havenāt done anything with this yet, beyond the updates to the doc
function shows specs as well as docstrings).
http://clojuredocs.org probably has the lowest bar for contribution: just login and start adding examples and see-alsos etc; the underlying infrastructure is on GitHub and accepts PRs if you think anything needs changing in the code. Next would be http://clojure-doc.org which is entirely managed on GitHub and the āguidesā team are happy to accept PRs (we need to automate the publishing after a PR is merged thoā). Finally thereās http://clojure.org itself, for which you need to sign a CA (to assign copyright of your contributions ā but you can do that electronically) and then submit PRs.
I want to ask about the core specs stuffā¦ but lemme ask this one firstā¦ Is there something wrong with trying to inject more detailed docstrings (maybe in a markup lang) for tools to look up?
And then thereās docstrings in Clojure/core itself which are treated as ācodeā and therefore need a CA and a patch, rather than a PR.
@U05380FG9 If the docstrings used markup, then all tooling, even the bare bones REPL, would need to deal with it. Thatās a bad idea. And thatās why the Clojure/core folks are so against that.
right~ but if we have a separate repository of just ābetter docstringsā, but community would be able to actively participate in making it betterā¦
The docstrings all end up in the clojure-x.y.z.jar file so thatās another reason for not wanting more detailed docstrings in the code.
add in some tooling to look up docstrings from that alternative sourceā¦ wouldnāt that work?
Sure, and anyone is welcome to set up a community project with ābetter docstringsā, in some form that tooling can use (data).
A web site that could yield arbitrary documentation in plain text, markdown, rendered HTML, etc from a GET /clojure/java/jdbc/query?format=ā¦ style URL would be great. Any volunteer or group of volunteers could do that, and seed it with the default docstrings until community members edited them.
Iāll observe that I moved the java.jdbc docs out of the contrib repo to http://clojure-doc.org specifically to get them out of the CA/patch process and into an open community GitHub/PR process. I did that ages ago. But almost no one has ever contributed to those docs, beyond me and (recently) one other community member.
Allowing the community to maintain external documentation is one thing ā and itās a good thing ā but actually getting people to contribute is something completely different. Lots of people love to complain about the state of Clojure documentation, but when it comes down to actually making it betterā¦ crickets š
(and since some folks have been complaining about the docs for years now, but community contribution levels remain low, youāll understand why the Clojure/core folks tend to be a bit unsympathetic to the complaints these days š )
yeah~ wellā¦ working on documentation probably doesnāt seem very appealing to people, unfortunatelyā¦ but it definitely is necessaryā¦
I looked into clojure.core with the other day. It reports there are 500+ public functions in there. Itās a bit daunting to have to replace that many docstrings.
I value the time the Clojure/core team spend on the code ā on Clojure itself and the power it provides us all. I donāt want them to āwasteā time on documentation instead. But Iād sure like to see more community members contribute to the various documentation sites.
@U05380FG9 Youād generate an initial version from the default docstrings in the core ā not much effort ā and then provide an editing mechanism for the community to expand those. It would be a slow, incremental replacement over time.
Thatās pretty much what http://clojuredocs.org does.
I actually hacked together something that will highjack CIDERās doc requests and inject it with new docstrings if availableā¦
https://github.com/clojure/core.specs.alpha ā mostly macros right now I think ā thatās part of Clojure 1.9 alphas (we have Alpha 20 in production).
okay~ having any kind of type info on the function params would help a whole lot. I canāt remember the number of times when I wondered āwhat kind of stuff will that function actually accept?ā
Being able to play with the function in the repl definitely helps. But, that seems to introduce unnecessary friction into the dev process and is likely to penalize newcomers to the language.
looked at Racketās api docs the other dayā¦ https://docs.racket-lang.org/collections/collections-api.html Itās rather nice that each functionās prototype is clearly outlined above any additional explanation.
I guess Iāve gotten used to just pressing ctrl-alt-, d
when I want to see docs (inline, in ProtoREPL). I tend to only have a few lines of the REPL open at the bottom of the screen and do everything in files and have ProtoREPL display inline results in the editor. Iāve also gotten used to Clojureās ālack of typesā so there are a lot of functions you donāt really need to know āwhat kind of stuffā they will accept, if theyāre written for a sequence, for example.
yeah~ I like the lack of strict types and the flexibility that comes with it. Still, when I first get acquainted with an api/function, it can get a little confusing.
For example, the api docs for āns-publicsā says: ------------------------- clojure.core/ns-publics ([ns]) Returns a map of the public intern mappings for the namespace.
do I pass it a string? do I somehow lookup an ānsā (as the param name suggest) first?
yeah~ The repl is very good for exploring an api. But, I think a little clarity in the docs will go a long way.
hi all š does anyone knows about a repl wathcher something like npm's nodemon that watch my files and when i change anything it reloads the repl ? same goes for tests, lintign etc...
For webserver, ring has reload middleware https://github.com/ring-clojure/ring/wiki/Reloading. But I would suggest you to reload manually with help from tools like https://github.com/weavejester/reloaded.repl or https://github.com/weavejester/integrant-repl
You might also want to take a look at https://github.com/danielsz/holygrail
itās got a setup where itāll refresh your repl automatically on file saveā¦ it helps to keep your repl in the same state as your source fileā¦
for variable names matching exactly with some builtin core function name, is there some naming convention to be followed for naming such variable?
eg, I have a function which accepts a parameter which represents name. I can not call it name
as it will conflict with the clojure.core function name
.
I have been using alternate names / short forms till now, wanted to check if there is some convention.
seems good, although it seems more like variable defined in a macro
calling it name
is valid, but you can also qualify it, as in foo-name
(where I canāt guess fooās real name without knowing more about your code)
Anyone here got experience with lacinia? I'm writing a graphQL proxy for a REST api, and I'm having problems traversing the REST endpoint and building
.. the data structure
The backend has data in the following format {object { children { list of objects } }, which can go on for a long time. However, I am only able to retreieve one level of children. Any suggestions?
@karlstefan try the #graphql channel
Thanks š
Hello everyone. We had a hard time implementing custom transducer that tried to supply itās initial value. If we take a look at transduce impl: (defn transduce ([xform f coll] (transduce xform f (f) coll)) ([xform f init coll] (let [f (xform f) ret (if (instance? clojure.lang.IReduceInit coll) (.reduce ^clojure.lang.IReduceInit coll f init) (clojure.core.protocols/coll-reduce coll f init))] (f ret)))) We can see itās 3-arity version invokes reducing function and passes it as initial value to 4-arity. I see the problem here. If we see Transducer as a transformer for reducer then we should never invoke f ourselves here. We should have passed it to xf, get the real resulting r-f and invoke this with zero arity only after transformation. Could anyone please clarify on this? Is it some misunderstanding on my side or itās just a bug?
Transducers shouldnāt supply an initial value
the transducing process does that
itās to pass through the transducer chain
As far as I can see arity-4 is to be implemented with 3: (defn transduce2 ([xform f coll] (let [fā (xform f)] (fā (reduce* fā (fā) coll)))) ([xform f init coll] (transduce2 xform (fn ([] init) ([r i] (f r i))) coll)))
Is this a surprise to anyone?
(clojure.data.json/read-str "{\"foo\": 43 \"bar\": 42}")
=> {"foo" 43, "bar" 42}
Note the missing comma in the json inputdata.json is a bit of a barebones json parser, so it doesn't surprise me. But I'm not sure why I'd ever care if bad JSON got parsed correctly?
Authoring test data that ends up working in clojure and then banging one's head against the wall trying to figure out why it doesn't work in another language? (or even after porting to cheshire maybe)
actually, for deftypes using the factory function ->Whatever is prefered to using the construtor directly
I would leave it, make mk-sym your special constructor name, and leave ->Whatever as the standard thing as an escape hatch so someone who doesn't want your special thing can avoid it
well the goal was to replace usage of defrecord
s with this (and add ILookup
etc to the type), and a lot of the code (which uses ->Whatever
to make thing
and does dispatch on (type thing)
) would stay the same
But the idea was to make a ārecyclableā type, where there are mutable fields behind the scenes, and the ILookup would return the current value, not whatever mutable container that held that value
I'm at the point where GC thrashing is my biggest issue. Time to try out gross stuff š
Having hyphen in folder name gives error but when i rename test_utils
to testutils
it works
java.lang.Exception: namespace 'com.pay.boomerang.config' not found after loading '/com/pay/boomerang/config', compiling:(com/pay/test_utils/helpers.clj:1:1)
there has been a similar question posted here but no actual reason of the problem -> https://stackoverflow.com/questions/12718658/why-does-java-complain-that-namespace-is-not-foundClojure, being a Lisp, allows -
in symbol names. Java, the compiled target host environment, does not. So when Clojure compiles com.pay.test-utils.helpers
, it produces a Java package com.pay.test_utils
containing a class helpers
. The file system must conform to Jaya's view of packages so it must be com/pay/test_utils
on the file system. Does that answer your question?
this is the real impl I have so far, btw https://gist.github.com/csm/1d2d708029a79db937c01b7d1c01dc30
In compojure-api
is there a way to mark a field in a schema as "deprecated"
so that it shows up in the swagger UI?
I am trying to get the *cider-error*
buffer to always display in the same frame. Right now it opens in the last window it was open in, which might be in another frame. I recently learned that there is a variable display-buffer-alist
that sounds like it might be useful. But it sounds like display-buffer
is not what's being used, since it displays the buffer without selecting it, but when an error occurs the error buffer is selected. Then there is pop-to-buffer
, switch-to-buffer
, etc. Anyway, does anyone know how I can get cider to always display the error buffer in the same frame, but not the same window?
@oskarkv when I used emacs winner-mode
saved my sanity - it gives you a history where you can undo and redo all changes to buffer layout in your pane https://www.emacswiki.org/emacs/WinnerMode - it comes standard with emacs you just need to turn it on
@noisesmith I'll check it out, thanks.
For now I figured I can delete the old buffer with an advice before cider tries to switch to it
http://clojuredocs.org probably has the lowest bar for contribution: just login and start adding examples and see-alsos etc; the underlying infrastructure is on GitHub and accepts PRs if you think anything needs changing in the code. Next would be http://clojure-doc.org which is entirely managed on GitHub and the āguidesā team are happy to accept PRs (we need to automate the publishing after a PR is merged thoā). Finally thereās http://clojure.org itself, for which you need to sign a CA (to assign copyright of your contributions ā but you can do that electronically) and then submit PRs.