Fork me on GitHub
Will Sanders00:06:14

is anyone running on VS Code with Calva


as of the last Clojure survey just under 20% or so of the Clojure community uses it. Far better to just ask a question than a question about your question. There's also #vscode and #calva channels specific to the editor and tooling

Jim Strieter04:06:17

Is there any way to get a REPL while debugging in Idea? For instance, if I set a breakpoint to line 103, and then debugger pauses at line 103, I want to type stuff at the repl like this:

my-project.core=> (get-in my-map [:key1 :key2 :key3])
Is this possible?


That might be a better question for #cursive since it is tool-specific. In general, that sort of thing depends on how breakpoints are handled. There are ways to have exception handlers start REPLs inside the program but there are generally a lot of caveats around it. I think there have been some conference talks about it over the years, although I'm not sure what to search for to find those...


Personally, I haven't used a step debugger and breakpoints in years... maybe not in decades... I used to use that approach with C and C++ and a little bit when I first started with Java but haven't felt the need for it since then, and never with Clojure. There are lots of debugging libraries that let you capture local environments, start REPLs, send values to additional visualization tools (REBL, Reveal, Portal). Given Clojure's dynamic nature, I find it easier to just instrument specific functions where I would have used breakpoints in C/C++.


I use cider debugger all the time and I find it very useful. It has a way to evaluate expressions when the program is stopped at a breakpoint but it it's not as convenient as typing into normal buffer or repl. Intellij has a way to evaluate expressions while the program is stopped but I don't know how well that is integrated in Cursive because I don't use Cursive

Yosevu Kilonzo05:06:07

Hello, what am I missing with this regex? I expect a separate string for each markdown link, but I get one string in the seq.


The problem is that \[.*\] is "greedy" and matches from the first [ to the *last* ]. You can get around that by using \[[^\]]*\] instead.


Or you can use the non-greedy match \[.*?\]


user=> (re-seq
  #_=>    #"\[.*?\]\(\)"
  #_=>    "more text [Link 1]() more text [Link 2]() more text")
("[Link 1]()" "[Link 2]()")

Yosevu Kilonzo05:06:13

Ah thanks sean, I was missing that concept. I will try it!


Regex is hard.

Yosevu Kilonzo05:06:51

Yeah. I'd like to get a better general understanding of all the concepts. Do you have any resource/reading recommendations?


Unfortunately, no. All I know about regex I've learned via Bing (and Google before that).


I will say it's important to make sure you're reading about the Java regex implementation and not other languages' regexes tho' -- there are some subtle and important differences at times...

Yosevu Kilonzo05:06:34

Oh I see. Well thank you! I didn't think to reference the Java regex docs.


I've found to be useful when puzzling through regexs. There are a few tools like this out there, this one does have the Java flavour available

๐Ÿ‘ 1

there's a really amazing resource for reqular expressions - covers all major flavors including java:


it's where I learned about free-spacing mode, which I love


(def input
  (str "more text [Link 1]()"
       " more text [Lin k 2]()"
       "more text"))

(def regex
  #"(?x)                                  # free-spacing / comments enabled
    \[.*?\]                               # starts with [....] describing link
    \(\) # continues with (...) containing link")

(re-seq regex input)

Yosevu Kilonzo06:06:51

Awesome, thanks robertftw and noisesmith!


I'd like to reduce output of db reads when testing. So given:

(defn pull [db id]
  ;; ...
  {:pull-result pull-result :pulled-ids pulled-ids})

(defn test-pull [db id]
  (let [{:keys [pulled-ids]} (pull db ids)]
    {:pull-result pulled-ids ;; note
     :pulled-ids pulled-ids}))
I'd like to be able to do something like this (which obviously can't work):
(with-redefs [pull test-pull]
How can I achieve this? Just redefining pull to identity is no good.


(defn pull [db id]
  ;; ...
  {:pull-result pull-result :pulled-ids pulled-ids})

(let [origin-pull pull]
  (with-redefs [pull (fn [db id]
                       (let [{:keys [pulled-ids]} (origin-pull db id)]
                         {:pull-result pulled-ids ;; note
                          :pulled-ids pulled-ids}))]
    (pull ...)))
try this


Hah, nice workaround ๐Ÿ™‚ Thank you!


quick question about ##. I only see it in the the context of ##Inf ##-Inf ##NaN. is ## used for anything else? what does it actually mean? thanks all ๐Ÿ™‚

Alex Miller (Clojure team)20:06:34

it's a symbolic value and it is not used for anything else

๐Ÿ™‡ 1

Hey, I'm trying to parse a document with instaparse, but I'm currently stuck parsing multiple lines. This is my grammar so far:

document = line
line = (<spaces*> word)* <eol>
eol = spaces* ('\n' | Epsilon)
spaces = ' '*
word = #'[\S]+'
but when I change the first line to parse multiple lines
document = line*
I get this as output
 [:line [:word "this"]]
 [:line [:word "is"]]
 [:line [:word "line1"]]
 [:line [:word "this"]]
 [:line [:word "is"]]
 [:line [:word "line2"]]]
does anyone know what I do wrong here? Any help is appreciated ๐Ÿ™‚


this seems to work:

document = line*
line = (<spaces*> word)+ eol
eol = spaces* ('\n' | Epsilon)
spaces = ' '*
word = #'[\S]+'


for this input:



try this as Input

this is the first line
this is the second


document = line*
line = (spaces* word spaces*)+ eol
eol = ('\n' | Epsilon)
spaces = ' '*
word = #'[\S]+'
this works


ok, I also got this to work:

document = line* lastline
lastline = (<spaces*> word)+ (eol | Epsilon)
line = (<spaces*> word)+ eol
eol = ' '* ('\n')
spaces = ' '*
word = #'[\S]+'


basically, every line must have a newline except the last line


for your most recent example, there are multiple valid parsers and some of them aren't right


ah cool, I tried something similar but ditched it because the actual grammar inside the line is more complicated and I didn't want to repeat the rules just for the last line ๐Ÿ˜„


Epsilon is just the empty parser. Trying to find if there's some that matches something like EOF


this seems to work:

document = line* 
line = (<spaces*> word)+ (eol | EOF)
eol = ' '* ('\n')
spaces = ' '*
word = #'[\S]+'
EOF= #"$"


thanks a lot


instaparse is awesome, isn't it? I wish I could use it more often to get fluent with it ๐Ÿ™‚

metal 1

document = line*
line = (<spaces> word)* <eol>
eol = spaces ('\n' | #'$')
spaces = ' '*
word = #'\S+'


Appears to work as well


I would probably still go with something like:

document = (line-content <eol>)* line-content (<eol> | Epsilon)
line-content = (<spaces*> word)* spaces*
eol =  '\n'
spaces = ' '*
word = #'[\S]+'


remove the <>


are you sure that is the grammar you are actually using?


ye pretty sure


for example:

document = line line
has the output I expect for 2 lines


if you remove the <> you can see exactly what instaparse parsed and matched for each production

๐Ÿ‘ 1

your issue is basically eol matches the empty string


0 or more spaces fallowed by a newline or the empty string


Do you know how to express "either new line or eof"?

Drew Verlee22:06:17

"\n" is new line ...