This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-09-12
Channels
- # beginners (63)
- # boot (3)
- # braveandtrue (153)
- # cider (19)
- # cljdoc (2)
- # clojure (80)
- # clojure-dev (25)
- # clojure-italy (73)
- # clojure-losangeles (1)
- # clojure-nl (4)
- # clojure-spec (67)
- # clojure-sweden (1)
- # clojure-uk (83)
- # clojurescript (56)
- # clojutre (11)
- # core-logic (37)
- # cursive (18)
- # datomic (14)
- # editors (10)
- # emacs (13)
- # figwheel-main (11)
- # fulcro (62)
- # graphql (11)
- # jobs (3)
- # klipse (1)
- # leiningen (6)
- # off-topic (91)
- # onyx (7)
- # pedestal (3)
- # portkey (5)
- # re-frame (14)
- # reagent (13)
- # remote-jobs (1)
- # shadow-cljs (111)
- # tools-deps (4)
- # yada (10)
I need to debug an private function parse-loc
failed which is defined in an library kce-clj
. When I invoke it in Emacs CIDER, it always has another middleware issue caused an exception. So I have to debug function in plain lein repl
, I'm running code:
(with-open [f ( "/home/stardiviner/Documents/learning/Clojure/kindle-export-notes/My Clippings.txt")]
(kce-clj/extract f "UTC"))
which kce-clj/extract
invokes parse-loc
internally. I got error:
NullPointerException clojure.string/lower-case (string.clj:217)
I want to add println
in parse-loc
private function so that I can know which line of file caused this error.
Does anyone have some way to do this?Often you can print a full stack trace showing all of the stack frames, each with its own file name and line number. Try (clojure.repl/pst)
Sometimes they can be fairly long and contain many lines you do not care about, but find the line that has clojure.string/lower-case (string.clj:217), probably near the beginning of the output (you may need to scroll back), and look at the next line or two for parse-loc.
@andy.fingerhut I got this output by (pst)
.
kindle-export-notes.core=> (pst)
NullPointerException
clojure.string/lower-case (string.clj:217)
clojure.string/lower-case (string.clj:213)
kce-clj.core/parse-loc (core.clj:26)
kce-clj.core/parse-loc (core.clj:23)
kce-clj.core/parse-cat-loc (core.clj:34)
kce-clj.core/parse-cat-loc (core.clj:30)
kce-clj.core/parse-meta (core.clj:50)
kce-clj.core/parse-meta (core.clj:47)
kce-clj.core/parse-entry (core.clj:57)
kce-clj.core/parse-entry (core.clj:53)
kce-clj.core/lazy-extract/fn--201 (core.clj:66)
clojure.core/map/fn--5587 (core.clj:2747)
nil
This doesn't give out too much information.
I found how, I redefined that privated function in the library namespace, and add println line before the function result. Then found which line of file caused this problem. Because some lines of file are Chinese, so parsed error.
i’m sure i’ve missed something, but does the manifold library provide an equivalent to core.async’s pipeline-async
in the sense of “kick off a bunch of processes that and then collect their results as they complete”? its stream map and reduce seem to wait for each deferred value to resolve before continuing.
this toy seems to behave the way i’d like:
@(let [ns (a/to-chan (range 10))
out (a/chan)]
(a/pipeline-async
4
out
(fn [n c]
(a/go
(a/>! c (a/<! (a/thread
(println "start " n)
(Thread/sleep (* 100 (rand)))
(println "finish " n)
n)))
(a/close! c)))
ns)
(s/reduce conj [] (s/->source out)))
but then this other toy seems to go more or less one-at-a-time:
@(let [limit 10
ns (range limit)]
(->> ns
(s/map (fn [n]
(d/future (println "start " n)
(Thread/sleep (* 1000 (rand)))
(println "finish " n)
n)))
(s/reduce conj [])))
@clarkenciel have you looked at zip
?
okay now i have
@(let [limit 10
ns (range limit)]
(->> ns
(s/map (fn [n]
(d/future (println "start " n)
(Thread/sleep (* 1000 (rand)))
(println "finish " n)
n)))
(s/stream->seq)
(apply d/zip)))
and that seems to behave how i’d like!i.e.
start 0
start 2
start 3
start 4
start 5
start 6
start 8
start 1
start 7
start 9
finish 7
finish 9
finish 0
finish 3
finish 8
finish 1
finish 5
finish 2
finish 6
finish 4
(0 1 2 3 4 5 6 7 8 9)
@clarkenciel right:
@(apply d/zip (map d/success-deferred (range 10)))
(0 1 2 3 4 5 6 7 8 9)
Hi. I'm trying to add levand/heat {:git/url "
to my deps.edn
and I'm getting Error building classpath. Manifest type not detected when finding deps for levand/heat in coordinate ... after the repo is cloned and checked out. Does this mean the included project is missing a deps.edn
?
Adding a deps.edn fixed it, but, for some reason, I also had to add a :deps/manifest :deps
.
levand/heat {:git/url ""
:sha "6f2dbba0c055b281e1624b5814fd84c27d64f7bb"
:local/root "/path/to/heat"
:deps/manifest :deps}
{:paths ["src"]
:deps
{org.clojure/clojure {:mvn/version "1.9.0"},
enlive {:mvn/version "1.2.0-SNAPSHOT"}}}
lein cljsbuild once
is stops showing warnings after a couple of times of running that command.
are you cleaning in between?
yes, I would assume if a cached artifact is used, you wouldn't get the warning
does lein know to clean the js artifacts cljsbuild makes?
a common configuration issue is creating a custom target js dir and not adding it to clean-targets
it's not automatic
did you customize where compiled js goes in cljsbuild? if so you also need to customize clean-targets
warning, that does mean lein will throw away everything in that directory when you clean
Just to make sure we are on the same page. You are talking about :compiler {:output-to "path/to/site.js"}
right
there's also output-dir iirc
lein help sample
shows, but it's pretty intuitive
looks like adding :output-to
to :clean-targets vector even works
err, [:cljs-build :compiler :output-to]
or something like that
would the vector work if :cljsbuild
is set up like this :cljsbuild -> :builds [(which is a vector with a single map)] -> :compiler -> :output-to
?
[:cljsbuild :builds :a-build-name :output-to]
or maybe just hard-code the output-to value instead
Does anyone has recommendations for referencing environment variables from the project.clj?
@jacob.haag do you mean something like environ? https://github.com/weavejester/environ
sometimes ~(System/getenv "FOO")
inside the project.clj works - depends on how much you need
yes, the ~ makes sure it works with lein
project.clj is in an implicit syntax-quote
Hi, I am in need of an introductory book for someone with little programming knowledge and none in functional programming. Do anyone have a good indication?
maybe consider “How to Design Programs” by Felleisen + Findler?
depends a lot on your goals of course