🦋 Welcome to the MAIN() IRC channel of the Raku Programming Language (raku.org). Log available at irclogs.raku.org/raku/live.html . If you're a beginner, you can also check out the #raku-beginner channel!
Set by lizmat on 6 September 2022.
Xliff \o 02:58
tellable6 2024-10-29T21:22:52Z #raku <SmokeMachine> Xliff I think this a simple, yet cool example: usercontent.irccloud-cdn.com/file/.../image.png
2024-10-29T21:48:25Z #raku <ab5tract> Xliff: or this new and improved version of FIRST which works in any block (not just routines) and which returns the value of the expression (which < v6.e FIRST does not)
2024-10-29T21:48:31Z #raku <ab5tract> Xliff: github.com/rakudo/rakudo/blob/76f6...kumod#L696
hey Xliff, you have a message: gist.github.com/cece21637905e3bd76...85e9f24061
SmokeMachine Hi! This is how I plan to make Red use RakuAST instead of its current way of knowing what is happening inside of map blocks to convert it to Red::AST to be able to prepare SQL queries. I'd like to know it anyone can spot any problem with that idea before I start implementing that... usercontent.irccloud-cdn.com/file/.../image.png 09:05
lizmat SmokeMachine: that's basically the intent: and you will find problems... but I don't see any yet 09:17
SmokeMachine Thanks. My next step then is make ASTQuery accent more than one id (#first#grep#map) (currently it’s only using the last defined one) and I’ll start implementing the Red side of that 09:20
patrickb I'd like to debug a performance issue in a Grammar of mine (Rainbow). Is there any tooling or well known approaches to debug / introspect the performance behaviour of Grammars? 11:16
antononcube @patrickb CommaIDE has Grammar tools. I plan to try them out in the new plugin, but forgot about it... 12:58
@patrickb I.e. are you using IntelliJ ? If yes, look into the grammar tools provided by the comma-2 plugin. 12:59
SmokeMachine Any plan on making it able to other editors to use comma tools? 13:18
ab5tract Not really, no 13:25
They are all tightly integrated with IntelliJ APIs
SmokeMachine :(
ab5tract There’s at least one VIM mode plugin for InteliJ though
ab5tract Not really, no 13:32
They are all tightly integrated with IntelliJ APIs
SmokeMachine :(
ab5tract There’s at least one VIM mode plugin for InteliJ though
SmokeMachine Yes… I have used that for some time while playing with comma… 13:32
ab5tract Once nvim delivers on its promise to be usable as a library, I think wrapping Raku around it could be promising 13:32
SmokeMachine But that would be great if there was a way to exporte those tools 13:32
ab5tract And/or embedding it as an IntelliJ plugin
ab5tract SmokeMachine: unfortunately it just doesn’t work like that for the most part 13:32
SmokeMachine Couldn’t that become an lsp, a dap plugin, or something like that? 13:33
ab5tract It’s all there on the git repo if you want to take a stab at it 13:33
ab5tract If you mean can the parser in Comma be used for LSP, again the answer is unfortunately no 13:33
ab5tract It’s tied directly into the classes that IntelliJ expects 13:34
ab5tract Also it’s generated and entirely impenetrable to mortals 13:34
SmokeMachine Here? github.com/Raku/intellij-ide-plugin 13:34
ab5tract Here: github.com/ab5tract/comma-plugin 13:35
ab5tract Though I haven’t touched the grammar thingy much at all, so the difference is slight 13:35
ab5tract Many many other things have been updated and improved, however 13:35
ab5tract Also that repo uses the old PITA build system 13:35
antononcube @ab5tract "Grammar thingy" == the standard grammar tools of the comma-2.0, right? 13:38
ab5tract Well there is a preview panel but I seem to recall there being a debugger as well 14:03
ab5tract I should make sure I’ve brought in everything from Comma “pro” 14:04
ab5tract For patrickb’s purposes, Log::Timeline support may be useful too 14:17
patrickb I just noticed Grammar::Profiler::Simple. That's probably the least effort way forward... 14:18
ab5tract Yeah that sounds perfect 14:33
lizmat weekly: dev.to/lizmat/an-end-to-magical-madness-5d52 15:46
notable6 lizmat, Noted! (weekly)
timo it occurs to me that the "toggle" method/function is a relatively constrained form of a relatively general state machine. i wonder if that lens helps figure out what we want to do with it 18:51
timo as in, there's a series of states, every state has a transition to itself, and a transition to the next state. the check at that point in the argument list is what allows a transition to the next state. each even/odd state either outputs the item it took from the input or outputs nothing, depending on whether you provide :off for the starting point or not 19:07
it's not technically an FSA since the "alphabet" of possible inputs is rather vast, and you wouldn't be able to enumerate all the objects for which "* > 5" is true 19:08
timo i say "rather vast" instead of "limitless" because your system has a limited amount of memory available, even if you add more machines to that system via network or whatever, that just makes the space larger, not infinite :D 19:09
librasteve timo: so far I have been able to think of two use cases for toggle ... one where it is used to weed out extreme inputs (eg cap and collar) and one where it is used to pick out the contents of a "packet" based on a specific delimiter (see the discussion issue for examples) - honestly neither of these are very compelling and the notion that the test chain is stepped according to the input data is quite bemusing to 19:38
understand what is going on
and honestly, it I really wrote a state machine I would maybe unpack it to a level that my states / edges were enums 19:39
timo a nice little DSL to build states would probably be cool. i can't think of a good use case for toggle that wouldn't be be easier to write as ff inside of a loop, i think 19:45
btw has anybody tried putting ff into one of the arguments of toggle? :D
(probably does nothing unless you use the same block multiple times, since it never evaluates the same one again after it has returned True once 19:46
but you know, unexpected combinations of features often lead to Fun)
antononcube Finite State Automata (FSA) can be nicely described using graphs. 20:16
I was thinking to make a demo of FSA graphs -- I did not plan to use OOP perspective. (E.g. "toggle method.") 20:18
Also, currently "JavaScripdt::D3" does not visualize graphs with loops and more than one edge between vertexes. (Needed for FSA graphs.) 20:20
timo ah, that's unfortunate. well, graphviz it is then ;) 20:27
graphviz offers different output formats, among which is svg. should work fine to show that inside a notebook cell i imagine 20:30
antononcube Yeah, the "Graph" package exports to different formats, dot/neato/graphviz included. 20:31
I think have Mathematica and Mermaid-JS the most, except the "Raku format." 20:32
That said, I think there is a JavaScript package that can visualize dot graph specs. I kind of forgot about that... 20:36
timo worst case, just cross-compile the programs to webassembly :D
but yeah i think i saw a graphviz.js or something in the past 20:37
having it be translated rather than manually rewritten would be good in terms of feature coverage and bug-per-bug compatibility, though
antononcube I sort of know how to render in Jupyter JavaScript code obtained from D3.js and Google Charts. Anything else for me is hard to figure out. 20:41
timo OK, don't take my random musings as requests or commands or anything! 20:42
antononcube Well, it is fine -- I just realized now that the most recent version of the VS Code Jupyter plugin can render "seamlessly" Mermaid. Hence, the "Graph" package can be used for FSA (in VS Code.) 20:45
timo oh cool 20:49
i've found myself wishing i could use graphviz's "x11" output to build something that the user can use to interact with my script, but there's nothing like that in there ... maybe jupyter + mermaid is an interesting avenue to explore here for me 20:50
there's a nice little "jquery plugin" that can take the output of graphviz's "svg" and turn it into an html page where you can highlight paths, pan by dragging, and of course with custom javascript you can do more stuff 20:51
i used that to make graphs from moarvm's NFA engine explorable. they can be rather immense
antononcube @timo Confirmed -- "Graph" objects can be "natively" rendered in Jupyter notebooks: 21:38
cdn.discordapp.com/attachments/633...50b9f&
librasteve @antononcube sorry to bug you - please can you point me to the recipe to install Jupyter Raku kernel with IntelliJ? 21:42
antononcube IntelliJ can access use Raku kernels installed by “Jupyter::Kernel” or “Jupyter::Chatbook”. 21:50
The latter has very detailed installation instructions.
timo what does the :f argument do? first i thought maybe force-based layouting but the one at the bottom looks like a fixed layout rather than simulation of forces 22:06
timo i can just look it up, sorry 22:13
huh, i don't see it, at least not in the main branch of the module up on github? 22:21
antononcube :f is short of :code-fences or :code-block. 22:45
@timo Should be showing in main GitHub branch of "Graph". 22:48
timo ah! there it is :) 22:49
antononcube If the Raku code cell has the magic spec "#% markdown" then cell's evaluation result is treated as Markdown code. Hence, after generating the Mermaid-JS representation of a graph it the code wrappers ```mermaid and ``` have to be used. 22:52
timo right, that makes sense 22:54
antononcube I am not sure how well Mermaid deals with multiple edges and loops (of graphs.) 22:56
Also, some (most?) graphs are hard to recognize because layered layouts Mermaid-JS uses. 22:57
timo ah, damn 22:58
i guess mermaid has a little bit of a focus on like, flowchart-like graphs, and stuff you would hand-author
not some graph you created from some dataset and you want to get an idea what it looks like
antononcube Right. 22:59
timo "render all graphs well" is an impossible ask. i can't fault them if they decide that's not the focus for their tool
antononcube I treat it as "just a crutch" when it comes to graphs. Otherwise it is very cool to have.
LLMs easily translte from- and to Mermaid-JS. 23:00
timo i'm really kind-of missing some very flexible tool that you can use for interactively exploring unwieldy graph-y data 23:01
there are a few, i'm not sure what my problems were when i tried a few
antononcube Mathematica.
timo i'm thinking less of doing queries against the data, and more getting the rendering into the shape i want, or to "walk" from node to node 23:02
or does mathematica also give me interactive widgets where i can drag stuff around, select nodes or edges and maybe hide them, maybe do a path search?
antononcube Yeah, Mathematica aka Wolfram Language (WL) does allow that.
timo i haven't used mathematica in a long long time
only by writing code, though? 23:03
antononcube BRB...
timo i'm not sure i could afford mathematica to try it out 23:05
antononcube Yes, WL is mostly for coding manipulation, but it does have graphics/plot interactive features.
Let me try the graph interactivity.
BTW, D3.js can work too for that, but that is requires JavaScript knowledge. 23:06
timo right. i have a mild splattering of that
antononcube I am not sure about Vega and Vega-lite systems -- I have seen a lot interactive tools with them, but have not used them.
timo oh, have you ever looked at the moarvm heap snapshot profiler? it also gives you a graph of all objects and how they relate to each other. if you're ever looking for more graph data sets that are closely related to raku in some way 23:07
SmokeMachine it seems RakuAST does not support Red yet... :( usercontent.irccloud-cdn.com/file/.../image.png 23:08
timo oh i didn't know about vega before, or maybe i did and forgot about it. gonna give it a look
SmokeMachine: too much meta-object-protocol shenanigans, i wonder? 23:09
does --ll-exception give you a stack trace at least?
SmokeMachine I suppose... I think my rakuast -> Red::AST translation will need to wait a bit more... :(
timo well, toss the stacktrace here and maybe wishes really can come true? 23:10
antononcube Here is WL / Mathematica interactivity demo:
cdn.discordapp.com/attachments/633...2c0b9&
timo ah interesting, so it's kind of a little handy toolbox of related functions (methods?) that it can apply for you with just a click 23:11
SmokeMachine www.irccloud.com/pastebin/I72NvW3Q/
antononcube Also, in principle, with LLMs code manipulation of graphs should be pleasant enough. (Doubt it for large graphs though.)
@timo Correct. I usually disable that, but it is good to see what it offers time-to-time. 23:12
timo fair enough
SmokeMachine timo: sorry, your name went to the snippet... ☝️
timo that feels like an interesting bridge between the "discoverability" that GUIs can offer, and the power and flexibility of DSLs like CLIs and what-not 23:13
SmokeMachine src/Raku/ast/package.rakumod:22 it seems...
timo that's possibly just an accessor
BRB feeding the cat
SmokeMachine yes, it seems to be... 23:14
antononcube Now, if you convert the graph into a plot (with GraphPlot) you can manipulate its graphics objects. (Vertices, edges, etc.) 23:15
cdn.discordapp.com/attachments/633...7dfcd&
Check this Graph visulization "guide page": reference.wolfram.com/language/gui...ation.html 23:17
@timo Is this question close to what you are looking for? math.stackexchange.com/q/13841/301115 23:19
timo hm, no i don't think that's what i wanted 23:30
timo that question is more about like, authoring tools? for when you have an idea what you want your graph to look like before you start making it 23:33
timo i'm thinking more along the lines of "i have nodes/edges data and i would like to figure out what the graph has to tell me" 23:33
antononcube Ok, I am back to WL-usage suggestions, then. 🙂 23:40
timo i appreciate your input :) 23:46
did you see my comment about the heap snapshot profiler? 23:47
antononcube Yeah — no I have not seen it… 23:54
timo if you're interested i can give you some example data in a format of your choosing 23:55
the heap snapshot analyzer currently mainly supports the operation to get a path to every object from the nearest root
i.e. nodes are GC-managed objects and edges are pointers from inside an object (or memory owned by it) to another gc-managed object 23:56
and finding the nearest root is useful to find why an object is kept around 23:57
moarperf also has a kind of graph explorer thingie that's kind-of half-baked
antononcube Hm… would JSON format work? How about CSV file, with columns <from to weight> ? 23:59