This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-06-25
Channels
- # beginners (32)
- # boot (1)
- # cljs-dev (25)
- # cljsrn (1)
- # clojure (35)
- # clojure-dev (6)
- # clojure-nl (4)
- # clojure-russia (12)
- # clojure-spec (13)
- # clojure-switzerland (2)
- # clojurescript (63)
- # cursive (9)
- # datomic (18)
- # dirac (32)
- # graphql (6)
- # luminus (8)
- # off-topic (18)
- # pedestal (5)
- # protorepl (1)
- # re-frame (30)
- # remote-jobs (5)
- # untangled (61)
- # yada (7)
How do you check if something is a collection?
This seems like it should be straight foward, but everything i try seems to have edge cases where it doesn’t work.
coll?
google failed me hard on that one…
seqable? nil
returns true. for reasons i’m to tired to investigate 🙂
it's hard coded into it as one of the cases iirc
strings are also seqable
it checks for null and says sequable if it is https://github.com/clojure/clojure/blob/42a7fd42cfae973d2af16d4bed40c7594574b58b/src/jvm/clojure/lang/RT.java#L551
(that link is to canSeq, which seqable? calls)
coll? is actually built in
it checks for clojure persistent collections (which include those plus set? and instance PersistentQueue)
yea, i forgot about coll?
and was trying to use seqable?
for completeness you could also check for instance java.util.Collection
not sure if there’s a better channel for this, but I’m wondering if anyone has a good resource for or idiomatic example of wrapping an http api in clojure/script?
This is mainly for educational purposes; my company is mostly Scala, but we expose an http api and I’d like to practice / perhaps make internal use of this.
I’m at that intermediate point with clojure where I can tell if an interface I’m using seems idiomatic and well thought-out or not, but I haven’t worked on any libraries myself yet — so I don’t know what I don’t know 😉
ok cool. I have actually used cljs-http before and it was great
maybe I didn’t phrase it right, and maybe those libraries solve my question and I need to dive into them
or maybe it’s just a wrapper design question in general (agnostic of language)
but I’m wondering: with a clojure/script library that wraps an api, I’m interested in best practices of what data types to return, how should the user interact with it (a client that can handle any verb/endpoint vs specific functions wrapping known endpoints)
reading further into those examples in case those answer my question :disappear:
It was how I interpreted your question, dw. I can't really say much as I haven't written much in the way of libraries in Clojure/script, but I can say to follow the general good clojure ideas, data driven, etc
:thumbsup: on just following clojure principles. I guess guidance with writing a library is what I’m really after
yikes! I bet. I know a good one (library) when I see one, and a bad one
but I’ve seen so many ways of tackling the problem, good and bad. Maybe a better question to have asked would have been: what others consider to be best-in-class clojure api wrappers