🦋 Welcome to the former MAIN() IRC channel of the Raku Programming Language (raku.org). This channel has moved to Libera (irc.libera.chat #raku)
Set by lizmat on 23 May 2021.
japhb Anyone know if there's a generic document tree module for Raku? I'm looking for something where I can build up a tree of DOM-like nodes, and then have multiple renderers to turn that tree into different output formats (which may not be text files, but could also be binary streams, immediate mode GUI output, etc.). 01:13
Looking at e.g. the available Markdown modules shows that they all assume they're going to produce HTML output, and don't allow just semantically saying "This is a document with a title, made out of sections, each of which has a header and some content, which is built of blocks that might be paragraphs or tables or lists, ..." 01:15
It's not a conceptual pain to make one, but I'd rather avoid creating Yet Another Way To Do It if there's something good already out there.
moon-child japhb: i mean, that sounds kind of like pod6 03:14
japhb moon-child: Hmmmm, that's actually a decent point. I wonder if it has a decent API for just building up programmatically (as opposed to parsing Pod). 07:13
raydiak m: my $p = Pod::Block::Para.new; $p.contents = "foo"; use Pod::To::Text; say pod2text $p 07:32
camelia foo
lizmat weekly: www.reddit.com/r/rakulang/comments...generator/ 11:20
notable6 lizmat, Noted! (weekly)
melezhik . 14:56
cnx hi, is there a way to supply a sub directly for the where clause? 15:39
lizmat m: sub a($a -->True) { dd $a }; sub b($a where &a) { }; a 42 # cnx 15:44
camelia 42
cnx thanks! 15:45
lizmat meh, that doesn't do what one expects
m: sub a($a --> False) { dd $a }; sub b($a where &a) { }; a 42
camelia 42
lizmat hang on
cnx does where apply ~~? 15:46
I cannot seem to find the relevant documentation on what should be valid
lizmat no, it does work.. if you call the right sub :-)
m: sub a($a --> True) { dd $a }; sub b($a where &a) { dd }; b 42 15:47
camelia 42
sub b($a where { ... })
lizmat m: sub a($a --> False) { dd $a }; sub b($a where &a) { dd }; b 42
camelia Cannot resolve caller ACCEPTS(Sub+{Callable[Bool]}:D: Int:D); none of these signatures match:
(Mu:U: Mu \topic, *%_)
(Mu:U \SELF: Junction:D \topic, *%_)
in sub b at <tmp> line 1
in block <unit> at <tmp> line 1
cnx ^ this is what I got and why I asked, but I wasn't sure if it was my bug
lizmat what does the sub specified in the where return? It should be something trueish to make dispatch work 15:49
cnx this was it: 15:50
sub valid(Str:D $names --> Bool:D) { so /^\w+$/ && 2 < .chars == .comb.unique.elems given $names }
when I used where { valid $_ } it works but it looks verbose
tonyo you can use where &valid 16:05
m: sub valid(Str:D $names --> Bool) { so /^\w+$/ && 2 < .chars == .comb.unique.elems given $names }; sub r($x where &valid) { $x.say }; r "abc"; r "a";
camelia abc
Constraint type check failed in binding to parameter '$x'; expected anonymous constraint to be met but got Str ("a")
in sub r at <tmp> line 1
in block <unit> at <tmp> line 1
tonyo m: sub valid(Str:D $names --> Bool) { so /^\w+$/ && 2 < .chars == .comb.unique.elems given $names }; sub r($x where &valid) { $x.say }; r "abc"; 16:07
camelia abc
cnx why did specifying Bool:D instead causing the problem? 16:10
moritz looks like a bug to me 16:11
cnx this gets weirder when used with MAIN, it just consumes the #= doc 16:47
melezhik weekly: www.reddit.com/r/rakulang/comments...s_with_r3/ 23:24
notable6 melezhik, Noted! (weekly)