Regarding streaming: use lazy seqs. If they are treated strictly somewhere, it's bug.
@cmf the group construct is sensitive to both right margin and nesting depth with an upper bound. Lazy seqs will be flattened on demand. That use of laziness is essential to the space guarantee.
@cmf seems like pass maybe shouldn't call str. Might be easy/safe to remove, if the same string-coercion behavior is recovered later in the print call (which you're going to override anyway, right?). if you file an issue (or a PR!) I'll take a look some night this week.
@brandonbloom Ok, I see. I actually wrote an interface last night using the lower-level primitives, and it's pretty nice, so I might just stick with that unless there's a good reason not to?
There is still some trickiness there that I couldn't solve with a tired brain at 1am. Since it's a recursive descent parser driven by an imperative lexer, converting that into a lazy seq was pretty funky.
I then realised that the main processing pipeline is a transducer, and since I have an imperative thing driving it and an imperative thing (printing) consuming it, I was wondering if I could just use a main imperative loop to "push" the formatting ops through the pipeline, but it sounds like you're saying that that may violate the space guarantee?
Or is that if I'm building using the higher-level primitives? That would make sense, thinking about it.
Ok, so I got this working by implementing my logic as a transducer which takes a string and outputs the low-level formatting ops for the interpretation of that string. Outstanding.
if there are any on-lookers: cmf & i discussed via external channels - goodness coming down the cursive pipe :-)
I'm trying to pretty-print some code, but rather than turn it into a string, I want to turn it into React elements to mount in a React app. Is that something I can do with fipp? Can I get it to return something more complex than a single string in the end?
@Peeja That's exactly the sort of thing @cmf did for Cursive just above ^^
it's not something that's particularly easy though
the Cursive IDE prints objects that intellij understands so they can be clickable, etc