This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-12-02
Channels
- # adventofcode (286)
- # aws (3)
- # beginners (243)
- # calva (4)
- # cider (51)
- # cljs-dev (8)
- # clojure (74)
- # clojure-conj (1)
- # clojure-france (1)
- # clojure-italy (1)
- # clojure-spec (21)
- # clojure-uk (22)
- # clojurescript (25)
- # clojurex (6)
- # code-reviews (5)
- # core-async (3)
- # cursive (1)
- # defnpodcast (1)
- # fulcro (29)
- # mount (1)
- # off-topic (85)
- # onyx (5)
- # other-languages (7)
- # pathom (6)
- # pedestal (6)
- # re-frame (20)
- # reagent (2)
- # reitit (8)
- # ring-swagger (10)
- # shadow-cljs (53)
- # spacemacs (8)
- # tools-deps (34)
is there a name for a map indexed by ID
(atom {33 {:id 33, :contents "hax", } 77 {:id 77, contents "ham"}})
an “index”? :)
just a reminder it's the start of the Advent of Code https://adventofcode.com/
And also #adventofcode 🙂 Also the Zulip channel allows for discussion of spoilers in a spoiler-free manner!
is there some compiler option that i can teach to leiningein to make redef's within the same file a hard error ?
I think eastwood supports this: https://github.com/jonase/eastwood#redefd-vars
thanks 🙂
looked around like an idiot for 10 minutes since i managed to be an idiot in the first place and redefined a test dataset creation in my test 😞
It appears that graal vm doesn’t like the bytecode generated by the locking macro. Can anyone think of a work-around? The best I can think of is a Java helper method.
there is an old ticket for this that has been through several rounds of discussion (also an issue on dalvik)
there’s a newer suggestion on there that I think is worth more investigation
Oh, neat. I vaguely remembered this ticket. Let me see if there's anything I can add there.
testing the approach there with graal and reporting your findings would be super helpful
Do you guys use custom functions to validate data structures (such as parameters from http-request?) I write my own right now, wondering if there are any popular libraries being used.
Not thinking about a schema/spec, but more of a way to say "Password too short".. etc
I always though spec was supposed to "run" during development/testing mode and not in production due to performance
aka with Instrumentation on
thank you for the advice @vale
Have any of the core data structures been extended with datafy
in RC2? If not, is that planned for the final release of 1.10?
@jarvinenemil you could use spec for validation in this way. if I was going to NOT use spec, I’d probably look at truss which is really just a lot of macro goo to make it easier to write assertions
@shaun-mahood there are some changes in core, no plans to add more
note that datafy is not needed if the response is already Clojure data
so the core data structures don’t need “datafication” - they just fall back on identity
there are built-in extensions in core though for Throwable, Class, IRef, Namespace
IRef covers vars, atoms, refs, agents
happy to take tickets if you think of something else interesting
@alexmiller Oh fantastic - I’ll play with it and see if I can figure it out. Couldn’t get nav working on nested vectors yesterday so I guess I’ll have something to play with on the plane ride home :)
shouldn’t need anything special for nested colls, but please do let us know if something seems wrong
Also going to have a look at https://github.com/bhb/expound, but before that I will check out Spec in Clojure 1.10.
user> (= (vals {:a 1}) [1])
;; => true
user> (contains? [1] (vals {:a 1}))
;; => false
user> (contains? (vals {:a 1}) [1])
Execution error (IllegalArgumentException) at user/eval3846859 (REPL:1408).
contains? not supported on type: clojure.lang.APersistentMap$ValSeq
contains? only checks indexes
lists don't have indexes
+user=> (contains? [:a :b :c] 1)
true
+user=> (get [:a :b :c] 1)
:b
the docs are clear about this
:user=> (doc contains?)
-------------------------
clojure.core/contains?
([coll key])
Returns true if key is present in the given collection, otherwise
returns false. Note that for numerically indexed collections like
vectors and Java arrays, this tests if the numeric key is within the
range of indexes. 'contains?' operates constant or logarithmic time;
it will not perform a linear search for a value. See also 'some'.
nil
there's a good argument the name is easily misleading, but that ship's sailed
Does anyone have any recommendations for keeping the REPL state clean? By clean I mean not polluted with old references to functions and vars. I semi-frequently find myself baffled at why a program isn’t working, only to discover it is because one function somewhere is out of date. Should I just be refreshing my repl regularly? Or are there any tools that help with this? I currently use Atom’s proto-repl.
Hmm. I haven't used proto-repl much. I find CIDER does a pretty good job by letting me evaluate a whole ns in the REPL, which covers the 80% case when my REPL is out of date
Anything past a simple program I usually reach for something like mount
to handle the stateful parts of my app though
Hmm, maybe there is a full namespace refresh command that I just overlooked somewhere. What do you mean by mount?
E.g. i can run mount/start
and it will start my http server, db connection pool, and read my config files
There are many different libraries for doing this. I like mount because it's pretty easy to setup
interesting, I’ll take a look at that. I like the idea of specifying exactly what happens with the state on a refresh
I sometimes just evaluate a ns-unmap to remove something from a namespace in case it was renamed
Useful when you rename tests for example
Good to know! I figured out what my problem this time; I was doing a full namespace refresh, but I just wasn’t seeing a small error thrown early in the file that prevented the rest of the namespace from being evaluated. one function was calling another further down the file, so it hadn’t been declared yet.
I'd expect AOT and clasffile generation to fail. Luckily you don't need those things.
that's the way my advent project is set up and so far no worries. although i named it 01 so they would sort well
i wondered because i think it's kind of funny to make the problems more and more time consuming as people approach time they're supposed to be spending with their families 😄
yes the problems will get harder. if you're not already in #adventofcode you should join
depends on the person 🙂 The puzzles don't actually get harder and harder (if that's what you meant). The author wrote about the difficulty here https://www.reddit.com/r/adventofcode/comments/7idn6k/question_why_does_the_difficulty_vary_so_much/dqy08tk/ cc @U06DQC6MA
is there any way of checking if something is a clojure zipper? I'm new to zippers and i seem to keep using zip functions on things that are not zippers
if you look at a zipper it's "just" a hash-map with a specific set of keys. I guess you could make a function that validates that the expected keys are present?
You can look at the meta
(meta
(zip/seq-zip '(1 2 3 (1 2 3))))
;; =>
#:zip{:branch? #function[clojure.core/seq?--5391],
:children #function[clojure.core/identity],
:make-node #function[clojure.zip/seq-zip/fn--9294]}
You could also check a thing is a vector?
with a second element that’s a map?
with the keys #{:l, :pnodes, :ppath, :r}
but I think the former solution is easier. 🙂
I didn't know about checking the metadata - if you look at what seq-zip returns before you do any traversal, it's just the input followed by nil, so that wouldn't be something you can reasonably test for anyway
so clearly checking the metadata is the reliable thing (or the keys on the metadata, since it's still just a hash-map)