This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-01-07
Channels
- # adventofcode (3)
- # announcements (6)
- # babashka (20)
- # beginners (53)
- # calva (11)
- # clj-kondo (11)
- # clojure (50)
- # clojure-argentina (4)
- # clojure-dev (1)
- # clojure-europe (14)
- # clojure-houston (1)
- # clojure-italy (2)
- # clojure-nl (4)
- # clojure-norway (3)
- # clojure-seattle (3)
- # clojure-uk (13)
- # clojurescript (2)
- # cloverage (1)
- # code-reviews (4)
- # conjure (2)
- # cursive (5)
- # datalevin (4)
- # datascript (33)
- # datomic (16)
- # events (1)
- # graphql (10)
- # gratitude (1)
- # honeysql (6)
- # introduce-yourself (2)
- # jobs (1)
- # lsp (88)
- # malli (8)
- # off-topic (3)
- # other-languages (4)
- # polylith (3)
- # re-frame (16)
- # reagent (17)
- # reitit (3)
- # releases (2)
- # remote-jobs (1)
- # rewrite-clj (3)
- # shadow-cljs (3)
- # slack-help (2)
- # sql (36)
- # testing (31)
- # tools-deps (41)
- # xtdb (23)
Hey, team! I’m trying to run -M:clojure-lsp format
, but the process stop at 10% and doesn’t to show anything. Has anyone had a similar problem? I appreciate any help with this.
that's odd, sounds like some kind of corrupted cache, could you try rm -rf .lsp/.cache
and try again?
Now, it worked! Thank you for your help.😀
Do you guys know if there is any library which can be used to generate test documentation in clojure?
What do you mean by test documentation?
Well i need to document the tests i have in my project. As to gain an overview of what business logic is being tested. Instead of having to update a document everytime a test is written, i thought it might be a start to generate this documentation using some framework. Maybe adding some metadata to every test and thereby keeping the documentation close to the code and easy to update
Maybe one of the tools discussed here could help you: http://clojure-doc.org/articles/ecosystem/generating_documentation.html
Is it possible to have 2 (:require …) on a namespace declaration? (Thinking about splitting :as-alias requires on 1.11-alpha)
yes, although why not do them both in the same require?
just for organization, as I have many namespaces that are only for ns keywords, not code namespaces
I can have all in one require, this was a nice to have if it was possible to organize the requires that are for code from the ones that are for ns-kw
You may find some linters object to multiple :require
clauses.
thanks all for the answers, clj-kondo doesn’t seem to complain, good to know it works
How can I figure out if some object satisfies a protocol if it is done via metadata? satisfies?
returns false when protocol is implemented via metadata
call a protocol method on it
Feel free to copy https://github.com/nedap/speced.def/blob/70fc9c7afce9d93677eb5bf639d66b8e7233f969/src/nedap/speced/def/impl/satisfies.cljc
in general, I think many uses of satisfies? are a smell that you are putting conditionality outside the protocol instead of inside a default protocol implementation
can a protocol specify a default implementation?
i know multimethods can but a protocol?
Yes, indirectly. From https://clojure.org/reference/protocols: > To define a default implementation of protocol (for other than nil) just use Object
or alternately by wrapping protocol method calls in functions and handling these default in some other way
@U2FRKM4TW that Object impl will take precedence before any metadata based ones so that will effectively disable extension by meta
Ah, wait, I tested incorrectly. What you wrote seems to be wrong:
=> (defprotocol P :extend-via-metadata true (a [_]))
P
=> (extend-protocol P Object (a [_] (println "a from Object")))
nil
=> (a (with-meta {} {`a (fn [_] (println "a from metadata"))}))
a from metadata
nil
Per https://clojure.org/reference/protocols, "Protocol implementations are checked first for direct definitions (defrecord, deftype, reify), then metadata definitions, then external extensions (extend, extend-type, extend-protocol)."
extensions to Object are the last category (external)
Hm it seems I read that wrong
is there a way to make Clojure use integers instead of longs in a literal? I'm trying to match the data (bellow) with the type definition (above) :
(def emps {:name "EMPS"
:rowdef [{:name "EMPNO" :type SqlTypeName/INTEGER}
{:name "NAME" :type SqlTypeName/VARCHAR}
{:name "DEPTNO" :type SqlTypeName/INTEGER}
{:name "GENDER" :type SqlTypeName/VARCHAR}
{:name "CITY" :type SqlTypeName/VARCHAR}
{:name "EMPID" :type SqlTypeName/INTEGER}
{:name "AGE" :type SqlTypeName/INTEGER}
{:name "SLACKER" :type SqlTypeName/BOOLEAN}
{:name "MANAGER" :type SqlTypeName/BOOLEAN}
{:name "JOINDATE" :type SqlTypeName/VARCHAR}]
:data [[100 "Fred" 10 nil nil 30 25 true false "1996-08-03"]
[110 "Eric" 20 "M" "San Francisco" 3 80 nil false "2001-01-01"]
[110 "John" 40 "M" "Vancouver" 2 nil false true "2002-05-03"]
[120 "Wilma" 20 "F" nil 1 5 nil true "2005-09-07"]
[130 "Alice" 40 "F" "Vancouver" 2 nil false true "2007-01-01"]]})
I'm working to implement a calcite example but I've hit the "Clojure uses long by default" issue here. I can fix the example above by changing the type to BIGINT, but wonder if I can make it work like it is
write a function that walks emps calling int on data that has a rowdef of SqlTypeName/INTEGER
not following exactly what is going on, but why don’t you have a problem with strings and SqlTypeName/VARCHAR
as well?
strings are mapped OK. Clojure uses long for integer literals. in the library there is a type cast to the sql type and it fails because long is bigger than Integer
somewhere, it whatever libraries they are using, there is a mapping between java types and sql types
using Apache Calcite. I wrote a small library to interface with clojure. the above example is to demonstrate how to use it on q clojure datastructure.
yes. so if its a problem on insertion, that seems to be the proper answer to me. I was thinking it also might be in comparing results in a test or something as well.
yeah, hard to say, no idea what emps is being passed to, which is where the error is actually happening, but presumably there is some place where a function f is being invoked on emps
is count on a vec O(1)?
ok, thanks!