Fork me on GitHub
#clojure
<
2017-08-09
>
mpenet07:08:51

would :foo:bar be considered a "valid" keyword ? (I know the reader happily accepts a bit anything, but I am thinking in terms of "the reader unspoken law")

mpenet07:08:41

I guess so, since it "inherits" from symbol rules and symbols state: "Symbols beginning or ending with ':' are reserved by Clojure. A symbol can contain one or more non-repeating ':'s."

dotemacs10:08:38

Hi, trying to create a healthcheck for Kafka. Something that tells me if the service can consume and produce to a topic. Have you done anything similar or are you aware of anything like that?

dotemacs10:08:02

If the above approach is not optimal, what direction would you advise me to look into? Thanks

avi13:08:09

hi, did you mean to post this to this channel? Seems more like a Kafka question than a Clojure question? I don’t mean to be obnoxious; I like and use both and I’m happy to help… just wondering what angle you’re approaching this via

henrik11:08:04

I have a map that has a :year and a :month entry. There are obviously valid and invalid combinations of these two integers. How do I write a spec that checks the combination of them?

mpenet11:08:52

(s/and (s/keys :req-un [...]) valid-date?)

henrik11:08:53

(it can’t be a date in the future)

henrik11:08:25

@mpenet Brilliant, thank you.

mpenet11:08:09

you have to write valid-date? in case it wasn't obvious 🙂

henrik11:08:58

That was obvious 🙂

octahedrion11:08:16

related: if the map had :month and :day keys, which had to be a valid combination (number of days in a month), how would you spec that ? what's the solution in general for combinations of things that might be in different parts of a data structure ?

mpenet11:08:14

you can spec your maps with multiple s/keys (and predicates) and then merge them, or s/and them

mpenet11:08:52

so one registered spec per group of things and (s/and ::foo ::bar ::baz) (or merge depending on your needs)

mpenet11:08:11

it's also a clean way to separate gen for these groups of dependent things (ex twitter.name twitter.screen_name twitter.profile_image_url), so that they make sense

janetacarr14:08:40

has anyone here used clj-debugger?

qqq16:08:31

Are there any projects to allow users to define .foo files, where the .foo files can have reader macros / other syntactical weirdness for supporting DSLs that 'compile down' to clojure?

noisesmith17:08:16

@qqq where would the file name to parser dispatch happen? are you thinking of integrating with the OS file picking, the browser or email client file picking?

noisesmith17:08:14

if you want to parse something that is mostly clojure but some custom parsing rules, it’s easy to make transit use this - transit parse takes a map for parsing dispatch and you can invent whatever tags you like and use them as first class args based on the file name

qqq17:08:06

@noisesmith : I want to be able to extend the compiler to support .foo in addition to .clj files

qqq17:08:17

and for *.foo files, I specify a separate reader/parser

noisesmith17:08:24

you fork clojure then

noisesmith17:08:26

and write some java

qqq17:08:44

I'd prefer to not fork clojure 🙂

noisesmith17:08:50

the language wasn’t designed to be extensible on that level

noisesmith17:08:30

the compiler was written in java and doesn’t have runtime extension points

qqq17:08:54

I see, I incorrectly thought the compiler was written in clj (and magically bootstrapped)

noisesmith17:08:23

a bunch of classes matching kinds of expressions, with emit methods on them https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/Compiler.java#L721

qqq17:08:28

I'd probably try to wrap clojure instead of hack on clojure

qqq17:08:49

in particular, I bet with the right injections, I can hack boot/lein to do interpose on the *.foo files

noisesmith17:08:50

if you are willing to define a preprocessor that takes format foo and outputs clojure - that’s a lot more doable

noisesmith17:08:02

you just can’t expect clojure’s built in loading / compiling to be extended

noisesmith17:08:07

(without forking)

qqq17:08:12

yeah, so maybe a preprocessor as a boot task

noisesmith17:08:27

you could look at the defunct cljx and what it did (superseded by cljc)

noisesmith17:08:48

well maybe not defunct - just not as useful for new projects going forward (I’m sure there’s folks still using it)

norman17:08:55

Maybe clojure will some day get something like Racket’s #lang

noisesmith17:08:08

my suspicion is the lack of this feature is intentional

qqq17:08:23

@norman: racket's #lang is precisely the motivation behind this

noisesmith17:08:28

common lisp had a user extensible reader, and Hickey seems to avoided that kind of thing

Garrett Hopper17:08:14

What's the point of marking clojure/clojurescript dependencies as :scope "provided" in a leiningen project? What exactly is affected?

noisesmith17:08:39

it means the consumer of your lib never pulls in the dep via you - it must ask for it explicitly itself

noisesmith17:08:45

(or get it via some other dep path)

Garrett Hopper17:08:04

So there's no point in including in for an end project? (not a lib)

noisesmith17:08:22

it’s especially useful when your lib / app will run in an environment where the given dep is preloaded

noisesmith17:08:33

@ghopper yeah, not much point there

Garrett Hopper17:08:41

:thumbsup: Thanks

qqq17:08:41

I think a concrete case of this is reagent / react

noisesmith17:08:42

unless you run in a container!

noisesmith17:08:14

in a container, your frontend may need things that the container should be getting without your input (think servelets / applets / that sort of thing)

Garrett Hopper17:08:34

That makes sense. :thumbsup:

Garrett Hopper19:08:10

Would it be true to say that every method of a multimethod must be the same arity as the dispatch function?

Garrett Hopper20:08:26

I just got an answer over in #scrum. Apparently cljs allows for extra arguments to functions which weren't defined, which I wasn't aware of.

qqq23:08:51

Is there any good way to read clojure codebases on an ipad? On a desktop, I generally use emacs + neotree - but on an ipad, jumping around code seems quite non-trivial.