🦋 Welcome to the MAIN() IRC channel of the Raku Programming Language (raku.org). This channel is logged for the purpose of keeping a history about its development | evalbot usage: 'm: say 3;' or /msg camelia m: ... | 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 8 June 2022.
coleman The Web::Request module; can it be installed with zef? 03:58
Example usage github.com/Raku/examples/blob/mast...t.raku#L20
guifa nine: if `$*W.install_lexical_symbol: $*UNIT…` installs a my-scoped var, how would an our scoped one be installed? 04:02
Voldenet coleman: you may be looking for `zef install Web` 04:10
guifa (although if it's not a simple one or two liner, I'll just hold off until RakuAST when I know it'll be much easier lol) 04:11
Voldenet but the package itself doesn't work for me 04:12
Voldenet if you need to make requests consider Cro::HTTP 04:20
or Http::Tiny for the most recent module
melezhik . 06:52
CIAvash: I've setup sparkyci for api sport football module, so if codeberg does not have it's own CI system you can you sparkyci , for example sparrowhub.io:2222/report/825 06:55
From HN I read people move from GH recently ))) 06:56
CIAvash melezhik: Thanks. It has CI, but it's in "closed testing phase" and you have to request early access. 07:22
tellable6 CIAvash, I'll pass your message to melezhik
abraxxa is it a bug, that the raku repl doesn't increment the number shown at the prompt when say is called? 07:56
tellable6 2022-07-06T16:57:24Z #raku <nine> abraxxa: as far as I can tell thats already the case
abraxxa nine: to what of my questions was this your answer?
killown why should someone give a try for raku and what his language is good for? 07:57
abraxxa killown: for me it's grammars and async/multihtreading 08:02
wrote a parser for the firehol config syntax which I wouldn't known how to do without grammars
killown lots os languages can do async and multistuff, but I am interested in this grammars, seems like good for any parser 08:04
killown what about speed, in case I need for example load 5gb log file and parse some stuff from it 08:06
abraxxa you have to benchmark your use case, but for me runtime performance isn't an argument against using Raku for me 08:09
killown always the fastest method is the good one, I am using rust to parse logs, hardware resources matters a lot, but just trying around new languages stuff and you said about grammars, seems interesting depending on the case 08:13
abraxxa, I am curious, what kind of issue did you have that only grammars could solve it for you 08:14
abraxxa killown: as I already wrote parsing Firehol config files 08:15
I had a custom Perl syslog parser for our network devices and it was faster than Logstash which I didn't expect
I don't know anything about Rusts regex capabilities, builtin or crate. But as this is old technology the most regex engines are quite well optimized I guess 08:16
killown abraxxa, if the thing is only about regex, even python can do that 08:18
so raku is just perl with name of raku 08:19
ok got it
thank you for all the explanations 08:20
abraxxa no, it's not, which is why it was renamed from Perl 6 to Raku 08:21
I don't know any other scripting language (compiled on execution) that can do true native multithreading 08:22
Perl, Python, PHP, Ruby at least
nine abraxxa: I meant that as far as I can tell all methods are usually documented 08:38
abraxxa nine: of isn't: docs.raku.org/type/Rat 08:41
nine guifa: our scoped variables are just entries in the package's stash:
m: my Int $i; module Foo { }; Foo.WHO<$bar> := $i; say $Foo::bar
camelia (Int)
nine abraxxa: Rat does not have a method called 'of'
abraxxa nine: sorry, yes, that was made clear yesterday. What is missing is VAR 08:42
nine abraxxa: VAR is not a method. It just looks like one. It's more like a macro and documented in docs.raku.org/language/mop#index-e...ax_VAR-VAR 08:43
abraxxa my point is that the documentation should be organized around the human user, not how it is implemented 08:45
nine abraxxa: that is certainly a valid point and something every doc author should strive for. I just don't see how it could be done better in this case. To stay with your example: VAR does not have anything to do with the Rat type. Not more than for example 'my'. Would you expect to have 'my' explained on every single type's documentation page? While a little repetition does not hurt (it's the basis of learning 08:50
after all), too much repetition will cause confusion again, since it makes it harder to find what's actually unique about Rat.
FWIW I am with you that currently the docs probably err a little too much on the side of "don't repeat too much". Raku is a big language and the examples for one feature often require understanding of many other features which a beginner won't necessarily understand yet. 08:54
That said, bringing a beginner into the language sounds like something that books are meant for. Of course it could be that people just don't read books anymore :) 08:55
abraxxa nine: the type docs show all methods inherited and I've expected the topmost type Mu to have the VAR method defined and so it shows up in every types' docs 09:00
for example even after 20+ years in programming I don't know what the term 'macro' means (besides from clusterfuck in Excel) 09:01
nine killown: grammars are not just regexes. They are really the next step in evolution. While some of the things you can do with grammars can actually be done with regexes, you really have to know them extremely well and even then it's tedious. You just know that these advanced features were bolted on. The re-thinking that went into grammars made them much easier to learn. 09:10
abraxxa: VAR is _not_ a method. Not on Mu, not on anything. 09:11
killown so this is some kind of regex but easier to use advanced stuff 09:12
abraxxa nine: maybe, but why would a user care when they call it like one?
thowe pattern matching in Raku is a leap forward... I was just reading a book on it and playing with some online examples; it is an eyebrow raiser 09:15
nine abraxxa: because it's only the "call" that's like a method. You will not find it for example in the results of a call to 'Mu.^methods'. And that's why listing it as a method could even cause more confusion. 09:19
abraxxa: Int() looks like a call as well. Except that in my Int() $i; it's actually a coercion type and not a call at all. There are just cases where syntax has been re-used and just because something looks similar on a first glance, it is not similar at all. 09:20
abraxxa nine: does a languageserver suggest if for autocompletion? How should a user know that it's available to call? 09:21
nine abraxxa: if it's a good language server, it will. If not, then the loss is not huge though. We are talking about a very obscure feature after all. A feature that's probably most useful for introspection. 09:24
abraxxa: At the end of the day, auto-complete is no susbstitute for really learning a language. If one wants to do advanced stuff (which needing .VAR clearly indicates), one will have to learn the language for real and that will require reading through the "Fundamental topics" section of the docs and not just the reference pages for types. 09:26
abraxxa objecting to documentation improvements won't help to get more users into the language... 09:27
nine Who is objecting to improvements? 09:29
abraxxa you are by not wanting to list those 'macros' or link to them in the docs 09:47
and that isn't the first time I'm turned down with docs improvements with some technical argument
nine If you think I'm making a technical argument (only) then I did not get the message across. 10:04
10:50 < nine> abraxxa: that is certainly a valid point and something every doc author should strive for. I just don't see how it could be done better in this case. To stay with your example: VAR does not have anything to do with the Rat type. Not more than for example 10:05
'my'. Would you expect to have 'my' explained on every single type's documentation page? While a little repetition does not hurt (it's the basis of learning 10:06
abraxxa: this ^^^ was the crucial message
abraxxa is 'my' something than can be called on every type?
nine Every type can be used with my 10:08
You can for example use every type as coercion type: Rat(). Should that be documented with every single type? 10:09
You can call meta methods on every type: Rat.^name. Should those be documented with every type? 10:10
Scimon I'm trying to get type coercion and binding to play nicely together. It's not going well, can anyone advise? (Example incoming). 10:17
Using my Tree::Binary class it does and Iterable Role and that's fine. If I bind a variable as a Tree::Binary I can then iterate through it. EG : raku -MTree::Binary -e 'class IntTree does Tree::Binary::Role::BinaryTree[Int] {};my $int-tree := IntTree.from-Str("1(2(3)(4))(3(4)(5))");.say for $int-tree' 10:19
That works.
(If I assign it then it doesn't iterate... I *guess* that makes sense).
I also have a COERCE function so I can assign using my IntTree(Str) $int-tree = "1(2)(3)" and *that works*
But my IntTree(Str) $int-tree := "1(2)(3)"... gives me a Str object. 10:20
v2022.06 10:21
lizmat m: my $l = (1,2,3); .say for $l; .say for $l<> # Scimon 10:22
camelia (1 2 3)
1
2
3
lizmat if it is in a variable, it is containerized. If an Iterable is containerized, it won't iterate with for
decontainerizing with <> is maybe a solution? 10:23
Scimon Ahhhh.
Well that deals with half my confusion.
Yup. Still the Coercion not working on binding feels like a bug. 10:24
lizmat well, I guess either it should work, or you should get a typecheck error ? 10:25
Scimon Yeah... and instead it does neither. I may try and make a smaller test case see if I can reproduce. 10:26
lizmat m: my Str(Int) $a := 42; dd $a.^name
camelia "Int"
lizmat vrurg_ ^^ ??
m: my Str $a := 42 10:27
camelia Type check failed in binding; expected Str but got Int (42)
in block <unit> at <tmp> line 1
lizmat feels worthy of an issue
Scimon Did I find a bug?
lizmat feels like to me now :-) 10:28
Scimon I'm looking at this code and documenting the bits I'd missed before (like the iteration options). 10:34
Geth problem-solving: 18890dc9f4 | (Elizabeth Mattijsen)++ (committed using GitHub Web editor) | solutions/language/Add-head-skip-tail-subs.md
Add solution for #328 (#329)

  github.com/rakudo/rakudo/commit/af31b1df89 made this change.
11:04
guifa nine: forgive my ignorant Q, but how would I add an entry to a package stash via action code? Just switch $*UNIT to $*PACKAGE ? 11:12
nine guifa: oh, in actions. Sorry, I missed that context. Look into $*W.install_lexical_container. It takes a :scope. But really....this sounds like bad timing for fiddling in that stuff. This is really what RakuAST is making so much easier it's not even funny. 11:29
So if at all possible, I'd suggest working with the rakuast branch instead.
guifa nine: yeah I know :-) I finally have gotten the hang of slangs, but I'm in the really awkward middle phase where it's super easy to generate the code with RakuAST, but things still need to be installed via $*W to be usable in the slang :-) 11:30
_Xliff nine: I want to emit a set of need statements into a given lexical scope. Does the existing set of macros allow for that or will I need to test with RakuAST?
Right now, if I use "macro A { quasi { need B; Need C; Need D } };" the compunits are not cvisible to the scope that called A. 11:31
: use experimental :macros; macro A { quasi { need NativeCall; NativeCall::CArray[uint32].^name.say }; }; sub a { A; NativeCall::CArray[uint32].^name.say }; a 11:36
m: use experimental :macros; macro A { quasi { need NativeCall; NativeCall::CArray[uint32].^name.say }; }; sub a { A; NativeCall::CArray[uint32].^name.say }; a 11:37
camelia No such method 'AT-KEY' for invocant of type 'VMNull'
in any at <tmp> line 1
in sub a at <tmp> line 1
in block <unit> at <tmp> line 1
_Xliff ^^ Oh, and there's that...
p6steve raku 14:36
lizmat you're damn right! 14:37
p6steve -m 'Nan.^name'
-m Nan.^name
m: Nan.^name 14:40
camelia ===SORRY!=== Error while compiling <tmp>
Undeclared name:
Nan used at line 1
p6steve m: NaN.^name
camelia ( no output )
p6steve m: say NaN.^name
camelia Num
p6steve phew
M: say "".^name
m: say "".^name
camelia Str
p6steve so both Num and Str have a "none" value of their type 14:41
does Int have similar? 14:42
Nemokosch Every type does, no? 14:43
p6steve I am trying to use something more concrete than (Int) 14:44
as in "its defined to be 'none'" 14:45
guess I will have to go with (Int) anyways since I want 14:48
m: (1,2,3).are
camelia ( no output )
lizmat m: dd (1,2,3).are
camelia Int
p6steve m: dd (1,2,3,(Int)).are 14:49
camelia Int
p6steve tx
m: <a b c>.are 14:50
camelia ( no output )
p6steve m: dd <a b c>.are
camelia Str
p6steve m: dd <a b c (Str)>.are
camelia Str
p6steve and so on
m: dd (1.0, NaN).are 14:53
camelia Real
p6steve m: dd (1e0, NaN).are
camelia Num
p6steve m: dd (1e0, NaN, (Num)).are
camelia Num
jaguart Whats the diff between .WHAT and .^name? 15:02
nine What gives the type object, name gives the type's name
jaguart ummm 15:03
p6steve I heard that .^name is to be preferred, not sure why
jaguart ok - makes sense, when I `say 0.WHAT` it stringify's the class into its name? 15:04
nine yes 15:05
p6steve m: say 0.^name.^methods 15:06
camelia (BUILD Capture COERCE Int Num Version pred succ match subst-mutate parse-base Date DateTime IO WHY WHICH Bool Str Stringy DUMP ACCEPTS chomp chop starts-with ends-with substr-eq contains indices index rindex Numeric gist raku comb subst lines split sa…
p6steve .^name seems to give you more than just a Str
m: say 0.^name.^name 15:07
camelia Str
p6steve OK - that's cool
jaguart where in docs can I find details on .are - it's hard to search for :/ 15:09
Nemokosch What even is it 15:14
jaguart looks like it's a List thingy that tells you about the List content type 15:15
m: say (1,2,3).are
camelia (Int)
jaguart m: say (1,2,'a').are
camelia (Cool)
jaguart m: say (1.0,0.2).are 15:16
camelia (Rat)
nine Method are is a recent addition (only introduced this year) that's not yet documented 15:19
p6steve .are returns the narrowest type that all items match 15:21
(guess it only applies to built in types??) 15:23
generally that is types that have ancestor Cool
docs.raku.org/type/Cool#Type_Graph 15:24
m: say ((Map),(Range)).are 15:25
camelia (Iterable)
jaguart oh that is nice :)
p6steve m: class Kid{}; my Kid $john; my Kid $anna; say ($anna,$john).are; 15:29
camelia (Kid)
p6steve nope applies to stuff youmake too
nine I think it would actually have been more difficult to restrict it to builtin types... 15:30
jaguart Hmm a lot of `Died with X::Method::NotFound` 15:32
m: say (1,2,3.0).are
camelia (Real)
jaguart Oh interesting - that `Died with X::Method::NotFound` in my REPL... 15:33
and works after restart
jaguart m: say ((Map),(Iterable)).are 15:38
camelia (Iterable)
jaguart m: say ((Iterable),(Map)).are
camelia No such method 'mro' for invocant of type
'Perl6::Metamodel::ParametricRoleGroupHOW'
in block <unit> at <tmp> line 1
jaguart m: say ((Map),(Iterable)).are 15:39
camelia (Iterable)
nine jaguart: why do you use those extra parentheses there? 15:47
nine m: say (Map, Iterable).are 15:47
camelia (Iterable)
melezhik . 15:48
tellable6 2022-07-07T07:22:55Z #raku <CIAvash> melezhik: Thanks. It has CI, but it's in "closed testing phase" and you have to request early access.
melezhik lizmat: Probably you're seen, just decided to tell just in case - I created a couple of GH issues for your modules test failures on sparkyci, hopefully helpful 15:49
you're -> you've 15:50
[Coke] github.com/Raku/doc/issues/4034 (the ticket for documenting .are) 16:59
(extra parens) you're outputting a type object, not a string. that's how the type object stringifies.
m: dd (Map, Iterable).are
camelia Iterable
[Coke] m: dd (Map, Iterable).are.^WHAT 17:00
camelia ===SORRY!=== Error while compiling <tmp>
Cannot use .^ on a non-identifier method call
at <tmp>:1
------> dd (Map, Iterable).are.^WHAT⏏<EOL>
expecting any of:
method arguments
[Coke] m: (Map, Iterable).are.new.^WHAT.say
camelia ===SORRY!=== Error while compiling <tmp>
Cannot use .^ on a non-identifier method call
at <tmp>:1
------> (Map, Iterable).are.new.^WHAT⏏.say
expecting any of:
method arguments
[Coke] oof.
m: dd (Map, Iterable).are.WHAT 17:02
camelia Iterable
[Coke] I was conflating ^name and WHAT. :) 17:04
`cal`to emit this month's calendar: 0.01s; raku to run 'say now': .7s 17:42
Guessing it's not worth trying to do any optimizations on App::Cal. :) 17:48
jaguart Coke: thanks for the correction - just assumed I needed the extra parens 18:25
japhb [Coke]: What kind of system has raku getting a .7s startup time? 18:26
(FWIW, it's less than .2s on my heavily loaded several-year-old laptop) 18:27
lizmat my 10+ year old MacMini it's .218 seconds
(running Debian)
on the 2 year old MacMini with an M1: .11 18:28
[Coke] my 2014 mac mini 18:42
it's .179 for -e1; 18:43
... numbers I'm seeing now are much faster. wtf? 18:44
might have had something running in the bg.
Anton Antonov I am looking for (much) faster alternative of "Text::CSV" -- any suggestions. (I should be able to easily run it on macOS.) 19:05
I am looking for (much) faster alternative of "Text::CSV" -- any suggestions? (I should be able to easily run it on macOS.) 19:06
[Coke] Not unless you're willing to cheat and not follow the spec.
text::csv is commonly used as a performance canary to ensure rakudo isn't slowing down; it's implemented by the author of perl5's version of the module. You're not going to find another implementation that's as accurate. 19:07
Anton Antonov @Coke Haha, ok. I tried cheating and failed...
Ok, good to know! (Almost all my packages use "Text::CSV" for resource data ingestion.) 19:08
[Coke] You could try Inline::Perl5 and perl5's version of Text::CSV - I believe that is reported as slightly faster.
yah, whenver I write something that needs CSV, if I try to cheat, I have to pull in T::CSV not long after. Have learned to just embrace it for consumption. 19:09
lizmat the Perl version of Text::CSV is about 6x faster, I believe 19:10
[Coke] even when used via rakudo? 19:11
lizmat ah... hmmm... possibly, :-)
Anton Antonov @lizmat 6 times faster motivates me to try it.
lizmat Anton Antonov: please let us know what you find! 19:12
Anton Antonov Will do -- it is a "real life" project with production level data. I trying to evaluate my Raku-implemented recommender over some of the data. 19:13
lizmat cool! 19:14
Anton Antonov BTW, my Raku implementation is a "reference implementation" -- it has all the features needed for most recommendations workflows and it is based on Mix objects. Usually, after ingesting the data works fast enough. 19:16
japhb
.oO( Transcode from CSV to CBOR using whatever's the fastest transcoder you can find, then use CBOR::Simple for loading the transcoded data )
19:32
Anton Antonov @japhb Great suggestion! I will try it out today. 19:39
@japhb "Transcode[r] from CSV to CBOR" -- Any suggestions? 19:42
japhb Thinking. 19:48
Is the CSV you're loading mixed text and numbers, or just pure numbers, or pure text?
p6steve japhb: there lies the problem ;-) 19:51
japhb p6steve: That you don't know? Or that it is mixed and weird? 19:52
japhb Hmmm, I'm seeing various premade JSON <-> CBOR transcoders, but not off the shelf for CSV. Actually, I wonder if having a pure-perl5 process that uses one of the faster CSV modules to load, then e.g. CBOR::XS or CBOR::Free to write, would be a fast enough transcoder. 19:55
p6steve btw you can use Dan::Pandas; my \df .= DataFrame.new; df.pd: '.read_csv("test.csv")'; 19:57
japhb Looks like Text::CSV_XS is the fast one on the Perl 5 side. 19:58
p6steve japhb: sorry - just reflecting that CSV slowness is because usually you don't know what's out there 19:59
japhb p6steve: Oh sure, I was just meaning, if you *happened* to know what the data sets roughly looked like, there are different ways you can do the transcode to speed things up. For example, CBOR has the concept of packed arrays ... if what you've got in each row is for instance all numbers, or a couple text fields and then a lot of numeric fields, you can take advantage of packed arrays to get much smaller and 20:01
faster.
Anton Antonov I am trying to use Python package called "cbor2" right now.
japhb Let us know how it goes! :-)
Anton Antonov 🤞 20:03
p6steve anton: IMO Inline::Python is OK for light use ... but I'm wary of pycall for heavy lifting 20:04
anton: I'm knee deep right now in Rust/Polars (thus this non-module github.com/p6steve/raku-Inline-Rust) 20:05
anton: would that help? 20:09
Anton Antonov <@928301352029937715> I was never able to install "Inline::Python" on my mac.
<@928301352029937715> Doing it with Rust !? 🙂 I am not sure. 20:10
p6steve container-service-1.gs7k0bfrb4gvk....r/eg?reset
password 'p6steve'
Anton Antonov Sounds good, thanks! Will try it in the next 30 min. 20:11
p6steve anton: please do have a play on the Jupyter - IMO Rust/Polars is the best engine (ie. no Python) 20:12
p6steve gnight 20:16
ah - need to restart lightsail ... 20:21
Anton Antonov Ok -- will do. 20:22
p6steve anton: new url -> container-service-1.gs7k0bfrb4gvk....tsail.com/ 20:26
anton: password 'p6steve' 20:27
Anton Antonov <@928301352029937715>, Do I have to have an account at amazonlightsail? 20:30
@japhb I got a CBOR file -- how do I read it in Raku? Using `slurp` with ":bin" ? 20:37
@japhp Yeah, I got it working. And, yes, the CBOR utilization gives me the fastest ingestion of ≈700MB CSV file in Raku. 20:49
nine [Coke]: according to the daily test runs, Text::CSV_XS via Inline::Perl5 is about 4x faster than Text::CSV. The valid comparison is csv-ip5xs-20 vs. test-t-20. The versions with fewer iterations are mostly comparing startup overhead. The --race version can't be compared because the benchmark doesn't include a threaded version using Inline::Perl5. 21:14
japhb Antonov: \o/ 22:44
Glad to hear that. :-)