🦋 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.
avuserow I'm getting a `429 Too Many Requests` errors often on raku.land. Is this for me or for everyone? 00:11
[Coke] i can hit refresh 20 times and get a 429 00:22
but normal clickthroughs seem fine
avuserow I seem to get it when searching. I wonder about the autocomplete, since it gives me results even with a single character typed which seems a bit eager 00:26
mort I don't really understand how to specify the return type of a function 00:30
`sub foo() returns Int` makes sense and all
but isn't it a bit important to communicate whether it returns an int scalar or an array of ints or a hash map of ints 00:31
00:37 jpn joined
[Coke] Int is a single Scalar Int. 00:39
you can define a subset of Array where all the elements are int and declare that as the return type if you like 00:40
er, Int
mort I guess my question is, if the body contains "my byte @foo = ... " and then returns @foo, what should I specify as the return type of the function 00:42
nemokosch m: my byte @foo = 1, 2, 3; @foo.WHAT.say;
evalable6 (array[byte])
Raku eval (array[byte])
nemokosch apparently it's array[byte] 00:43
a native array of a native (meaning, C compatible) integer type
mort isn't the @() thing sometimes array and sometimes list
[Coke] an Array is a List, so you can use that. 00:46
mort Array and List or array and list
[Coke] or use Iterable or Positional
m: dd array
camelia array
[Coke] any lowercase type is a native. if you want native, use that. 00:47
mort how do I know if I want a native or a non-native?
this might be better in #raku-beginner maybe 00:48
[Coke] if you don't know, you want non-native
mort so I want Array[byte] I guess
[Coke] natives arten't objects, you get a more compact representation, but you auto-coerce them to objects doing most operations on them.
mort I see 00:49
m: (10, 20).WHAT.say; 00:50
camelia (List)
mort I'm guessing you can't really express "a 2-element list where the first element is an int and the second is a string" 00:52
[Coke] was trying to come up with an example, but:
m: sub foo(--> Array of Int) { my @a = 3,4,5,6; return @a }; dd foo
camelia Type check failed for return value; expected Array[Int] but got Array ([3, 4, 5, 6])
in sub foo at <tmp> line 1
in block <unit> at <tmp> line 1
mort how do people declare the return type when doing multiple returns of different types? 00:53
nemokosch I mean maybe you don't want byte in the first place 00:54
or like, do you
mort sorry, these are separate things; the Array[byte] thing is very definitely a byte array 00:55
00:55 MasterDuke joined, sdfgsdfg joined
mort but the multiple returns thing is separate 00:55
nemokosch they aren't really separate but I wouldn't sweat too much on that
By the way, working with typed arrays is just painful. That absolutely isn't your fault, don't let anyone gaslight you, it should just be better
mort apparently there's a place where I am returning an array[byte] so it doesn't fit the `returns Array[byte]` 00:57
00:58 antim0d3s left
MasterDuke types in raku are nominal, i.e., depending on their "names". not structural, i.e., depending on their "shape" 01:01
so e.g., `sub foo(Int @bar) { ... }` need to be passed something that is explicitly an array of Ints, not just an array that happens to only contain Ints 01:03
and yes, it can be annoying/tricky
mort I guess the closest analogy to something I'm familiar with would be boxed types in Java right, where `return 10` doesn't work if the function returns an Integer rather than an int 01:04
is that somewhat the right track?
nemokosch We can talk about types being "nominal" but that's not really a useful framing... it's really just that there is no inference 01:06
MasterDuke but your request would be done via something like `subset Int_and_Str of List where { .[0] ~~ Int and .[1] ~~ Str }; my Int_and_Str $a = (1, "b"); dd $a; my Int_and_Str $b = ("a", 2); dd $b` 01:07
m: subset Int_and_Str of List where { .[0] ~~ Int and .[1] ~~ Str }; my Int_and_Str $a = (1, "b"); dd $a; my Int_and_Str $b = ("a", 2); dd $b
camelia List $a = $(1, "b")
Type check failed in assignment to $b; expected Int_and_Str but got List (("a", 2))
in block <unit> at <tmp> line 1
MasterDuke i mention nominal vs structural because those are words/concepts people might be familiar with 01:08
oh, guess i should have added an `.elems == 2 and` at the beginning of the where 01:10
01:11 Xliff_ joined
Xliff_ antoncube: You around? 01:11
Is there a service that can create Gantt charts from a text description? 01:12
01:14 mort left 01:15 mort joined
mort is there a way to write an array[byte] to a file? The write method takes a Blob, and logically, array[byte] is a blob but I don't know how to make the types happy 01:16
MasterDuke mort: i think so. though raku is sort of the opposite in the details of that example, in that the literal `10` is an Int, not an int 01:17
mort actually maybe I should be using Buf throughout rather than array[byte]
MasterDuke does `my array[byte] $a .= new(1, 2, 3, 4); "foo".IO.spurt($a)` do what you want? 01:20
mort I don't know, but using Buf does what I want so I'm happy 01:26
I kind of ended up writing a compiler for my first raku project 01:31
MasterDuke accidents happen to the best of us, don't beat yourself up about it 01:37
for what language? 01:38
mort MasterDuke: my own silly little language, for my own silly little VM 01:52
MasterDuke: p.mort.coffee/VnO.auto here's the source code for this compiler so far 02:03
it's very bare bones
but hey, it now manages to compile `x = 10; y = x; dbg-print y` 02:04
02:39 jpn left 02:40 jpn joined 02:43 constxqt_ left 02:49 hulk joined 02:50 kylese left 02:57 edr left 03:02 jpn left 03:05 constxqt_ joined 03:15 hulk left, kylese joined 03:16 constxqt_ left 03:22 constxqt_ joined
MasterDuke nice 03:25
03:35 constxqt_ left
mort p.mort.coffee/4Vi.png it does the thing 03:35
as you can see, this is a super serious project, the virtual machine lolvm and the programming language lol 03:36
03:41 constxqt_ joined 03:48 constxqt_ left 04:08 constxqt_ joined 04:24 constxqt_ left 04:27 constxqt_ joined 04:34 constxqt_ left 04:40 constxqt_ joined 05:06 constxqt_ left 05:19 constxqt_ joined 05:26 constxqt_ left 05:45 constxqt_ joined 05:50 constxqt_ left 06:08 MasterDuke left 06:48 constxqt_ joined 06:53 constxqt_ left 07:13 constxqt_ joined 07:18 constxqt_ left 07:39 avuserow left, avuserow joined 07:41 constxqt_ joined 07:46 constxqt_ left 07:56 constxqt_ joined 08:11 constxqt_ left 08:26 constxqt_ joined 08:27 teatime left 08:31 constxqt_ left 08:54 Xliff__ joined 08:57 Xliff left 09:01 constxqt_ joined 09:06 constxqt_ left 09:24 sena_kun joined 09:29 constxqt_ joined 09:38 constxqt_ left 09:41 jpn joined 09:42 sena_kun left 09:46 lichtkind__ joined 09:48 Sgeo left 09:55 constxqt_ joined 10:00 constxqt_ left
Geth planet.raku.org: e75add3751 | Andinus++ | perlanetrc
Update paths
planet.raku.org: afc6548793 | Andinus++ | perlanetrc
Update 'url' to 'feed'

perlanet emits these warnings:
   Your config file uses 'url' for the URL of the feed. Please update
   that to 'feed'.
The attribute was renamed in this commit:
planet.raku.org: 9caa4ddce9 | Andinus++ | perlanetrc
Remove perl6maven.com feed

The domain has expired and was registered by a "dropcatch" service -- registers expired domains.
Other feeds that misbehave currently:
  - wakelift.de/rss -- 404 Not Found
  - cry.nu/feed.xml -- Validation Failed (perlanet error)
  - hoelz.ro/perl6.rss -- 404 Not Found
10:27 constxqt_ joined 10:32 constxqt_ left 11:03 constxqt_ joined 11:08 constxqt_ left 11:36 constxqt_ joined 11:42 constxqt_ left 12:04 constxqt_ joined 12:10 constxqt_ left 12:17 xinming left 12:19 xinming joined 12:21 jpn left 12:25 constxqt_ joined 12:48 constxqt_ left 12:56 clarkema1 joined
lizmat It's advent calendar time again: raku-advent.blog 12:56
13:06 constxqt_ joined 13:11 constxqt_ left 13:15 constxqt_ joined 13:23 notagoodidea joined
notagoodidea Hey there, is there a place that collect AOC solutions in Raku by any chance ? 13:23
lizmat I don't know, but if you find out, please do a weekly: here so I can mention it in the weekly on Monday 13:26
notagoodidea Noted :) I will look a bit more around, thanks ! 13:27
andinus codesections has been creating repo every year github.com/codesections/advent-of-raku-2022 13:28
13:28 constxqt_ left
Geth advent: librasteve++ created pull request #108:
add librasteve
notagoodidea Thanks andinus, will see if @code 13:32
Thanks andinus I will see if codesections do it again this year :) I also found this one : github.com/Bogdanp/awesome-advent-of-code#raku 13:33
13:38 lichtkind_ joined 13:39 constxqt_ joined
notagoodidea (For what is worth, I am putting mine here for now : github.com/notagoodidea/aoc23 ... Beginner warning, having some fun :) ) 13:40
By the way, si there a way for `trans` to do multiple pass besides calling it twice? I did not see anything in the documentation so far :/ 13:41
13:41 lichtkind__ left 13:44 constxqt_ left 13:45 constxqt_ joined 13:53 jpn joined 13:58 constxqt_ left
[Coke] no, you'd have to loop. 14:00
if you need to do something a specific number of times you can: 14:01
m: say 3 for ^4
camelia 3
14:01 constxqt_ joined
notagoodidea Oh I forgot about the ^x syntax :D 14:03
m: $_.trans(<a b c> => <xa yb zc>).say for ^2 for <abc bbb> 14:05
camelia ===SORRY!=== Error while compiling <tmp>
Missing semicolon
at <tmp>:1
------> trans(<a b c> => <xa yb zc>).say for ^2 ⏏for <abc bbb>
[Coke] the ^2 is just if you're doing it twice with no other considerations, if you want to run it for each of two inputs, it's not needed. 14:09
m: $_.trans(<a b c> => <xa yb zc>).say for <abc bbb> 14:11
camelia xaybzc
notagoodidea Yeah, my brain did not connect. I was looking for another way to do x.trans().trans() in order to apply it twice in sequence (so feeding the output of the first trans into the second one)
[Coke] that is running it for two different inputs, I had thought you were looking for an iterative approach
ah, you are. 14:12
m: my $a = "thingstuff"; $a.= trans(<i u > => <u x>) for ^2; say $a 14:13
camelia thxngstxff
[Coke] you could also do the .= line until some condition was met, if it's not a simple # of iterations 14:14
notagoodidea m: my $a = "abc"; $a .= trans(<a b c> = <x a z>) for ^3; say $a 14:18
camelia Cannot modify an immutable Str (a)
in block <unit> at <tmp> line 1
notagoodidea m: my $a = "abc"; $a .= trans(<a b c> => <x a z>) for ^3; say $a
camelia xxz
14:24 dutchie left 14:26 dutchie joined 14:43 melezhik joined
melezhik o/ 14:43
how can I do introspection of Raku function?
say, I have a Raku function and I'd like to dump it's signature
for example - list of named parameters
is it possible?
nemokosch m: sub demo(:$foo, :$bar) { ... }; &demo.signature.say 14:44
evalable6 (:$foo, :$bar)
Raku eval (:$foo, :$bar)
melezhik I have a 60-80 Raku functions/classes and I'd like to have a sort of autogenerated documentation accessible via web , where a user could see those classes private attributes and / or functions signature 14:45
lemme git it a try, nemokosch
El_Che it does not say much or rather absolutely nothing (CI setups, repo metadata updates, etc) but since moving to the CloudSmith repos rakudo-pkg has had 42515050 according to them :) 14:49
linkable6 (2022-08-07) github.com/openstreetmap-polska/ae...425150507c AED update (C: 0, M: 0, D: 0)
melezhik nemokosch - can I dump class private attributes ? 14:52
14:52 constxqt_ left
nemokosch well, the attributes metamethod will give you all; it doesn't care about "privacy" 14:53
melezhik thanks 14:54
14:57 edr joined
ugexe tbrowder_: you could simply check-https further by doing just `sub check-https("path/file" --> Bool { so shell :!out, :!err, "curl -1sLf path/file -o /localpath/file" }` 15:01
no need for `try`, as shell won't return an exception (just a Failure), and so will boolify as appropriate without exploding the Failure
15:02 constxqt_ joined
ugexe and quietly isn't needed if you just disable stdout and stderr on the process via :!out :!err 15:02
15:18 melezhik left 15:23 notagoodidea left 15:48 melezhik joined
melezhik m: 'class Foo { has $!a = "hello"}' 15:48
camelia WARNINGS for <tmp>:
Useless use of constant string "class Foo { has $!a = \"hello\"}" in sink context (line 1)
melezhik m: 'class Foo { has $!a = "hello"};  for Foo.^attributes -> $I { say $i}' 15:49
camelia WARNINGS for <tmp>:
Useless use of constant string "class Foo { has $!a = \"hello\"};  for Foo.^attributes -> $I { say $i}" in sink context (line 1)
melezhik m: 'class Foo { has $!a = "hello"};  for Foo.^attributes -> $I { say $i}' 15:53
camelia WARNINGS for <tmp>:
Useless use of constant string "class Foo { has $!a = \"hello\"};  for Foo.^attributes -> $I { say $i}" in sink context (line 1)
melezhik how can I print out the content of Raku class attribute? 15:56
looks like this - docs.raku.org/type/Attribute#class_Attribute 16:03
[Coke] in your use of m: there _ don't wrap the code in quotes, and your $I and $i don't match 16:09
m: class Foo { has $!a = "hello"};  for Foo.^attributes -> $i { dd $i.name } 16:12
camelia "\$!a"
[Coke] I think once you have the attribute, you have to ask the instance what it's value is, I don't think you can get it directly from the Attribute itself.
m: class Foo { has $!a = "hello"};  for Foo.^attributes -> $i { dd $i.name, $i.get_value(Foo.new) } 16:14
camelia "\$!a"
Str $!a = "hello"
16:14 Sgeo joined, donaldh joined
[Coke] you can't get attributes from a type object, so we create a new foo, and use the attribute to ask that what it's value is, then you get the default 16:14
Geth advent/main: d0b2b5ade8 | librasteve++ (committed using GitHub Web editor) | raku-advent-2023/authors.md
add librasteve (#108)
16:29 melezhik left 16:31 MoC joined 17:08 MoC left 17:38 dpb left 17:41 dpb joined
librasteve o/ 18:08
my advent post draft is ready on Wordpress - please can someone with the powers schedule it? 18:09
tbrowder__ ugexe: good points, but shouldn't we encourage not usinf 18:10
librasteve wordpress.com/post/raku-advent.blog/2754
tbrowder__ *using shell unless absolutely necessary? 18:11
lizmat librasteve: ready to be scheduled?
librasteve yep
btw I can possibly squeeze another one out in a week or so if demand is there 18:12
lizmat librasteve I'd say the demand is there :-) 18:13
ugexe tbrowder__: sure, you can use `run` instead as well. you used shell in the post so i just reused that 18:16
Geth advent/main: 5f5366f43b | (Elizabeth Mattijsen)++ (committed using GitHub Web editor) | raku-advent-2023/authors.md
Publish Steve Roe's post on 5 December
ingy For those who recall my promise to bring YAMLScript to Raku... 18:45
Started my first advent blog today: yamlscript.org/blog/ :)
18:45 sena_kun joined
librasteve ok ... i'll stick part 2 in for 18th ish then 19:01
19:05 gdown joined
lizmat librasteve cool! 19:06
Geth advent: librasteve++ created pull request #109:
add part2 on 15th
advent/main: 4c984212df | (Elizabeth Mattijsen)++ (committed using GitHub Web editor) | raku-advent-2023/authors.md
Add Steve Roe 2nd post on the 15th
gdown What's the difference between a lookaround and lookahead assertion? Aside from this example in the documentation: `say '333' ~~ m/^^ \d+ <!:Script<Tamil>> /;`, they seem to function equivalently, and I'm not even sure why they work differently there. 19:14
19:35 jpn left
clarkema1 What's the process for proposing a change to the default dist of a module you get by just running 'zef install Foo' without any further qualification? 19:59
I'm not super up to date with ecosystem and module changes
20:10 Maylay left 20:23 Maylay joined
librasteve clarkema1: in the first instance, please raise an issue on the module repo 20:40
20:53 jpn joined
ab5tract clarkema1: do you mean you would vote for Foo:auth<D> to be default, but currently is Foo:auth<A>? 21:00
*it is 21:01
I don't know if there is something like that... I think the official answer is to always specify auth. 21:03
FWIW, I think what zef should do there is not install, but present you with a list of the matching packages instead. 21:04
librasteve oh, i see ... fwiw i think that most users are not going to know which one they want so there should be a (good) default 21:06
ab5tract librasteve: The date of the most recent update / other community stats could be shown
even links to the code
librasteve well, yes, but ask the user each time, really?! 21:07
ab5tract potentially even the download volumes.
librasteve: for conflicting packages, yes 21:08
clarkema1 My interest is primarily in the Readline module, which is the first thing that's recommended for a better experience when you start rakudo and seems to be abandoned
it's slowly been accumulating path issues for a few years
ab5tract librasteve: I would consider this a community service for module authors such that people would actually know their alternative even exists 21:09
librasteve amen to that
(ie. amen to 21:10
fixing Readliine)
ab5tract: your community service will require many (5ish?) of selections of deps in a typical zef install, neh? 21:12
ab5tract if module authors are not bothering to include auth, that's a different story
extremely poor hygiene 21:13
librasteve: by the logic of switching to a new default, this would happen invisibly
21:13 Xliff joined
ab5tract s/this/a dependency shift/ 21:14
clarkema1 At this point i'd be happy to fork it, but there would have to be a discussion about how that module becomes the default 'Readline', or whether it gets adopted into some kind of community management 21:15
There's not much point me fixing it for myself but leaving newcomers who just 'zef install Readline' on macos to struggle
librasteve i guess right now that you bump the version in your fork and it will win (?)
ab5tract I don't know if it works like that, but it would be kind helpful if it does 21:16
clarkema1 I've just installed it directly for testing. I really home it doesn't work like that, because it would open up a huge hole in terms of people hijacking namespace with malicious modules 21:17
ab5tract actually scratch that, then I can release a malicious version higher than yours and just win
clarkema1 I assume there's a blessed list somewhere that zef uses
librasteve yes, it works like that (I know since I changed my username to librasteve and now only see the latest ones of my modules) 21:18
ab5tract ok, that's somewhat alarming.. 21:21
librasteve i guess its blessed as in "this author has not been blocklisted" 21:22
ab5tract clarkema1: it sounds like the world of Readline supremacy in Raku is at your fingertips 21:23
clarkema1 That's a scary thought
ab5tract :) 21:24
clarkema1 I'm slightly terrified if I can just bump the version and push to CPAN
librasteve please push it to fez ;-)
clarkema1 I might try a little more testing first ;-) 21:25
librasteve couldn't be worse than the current one
clarkema1 Don't want to cause more problems than I fix
ab5tract go ahead and take your time 21:26
librasteve idea - give it the same version and invite some of us to help test
ab5tract you can always release yours at the same or lower version as base
clarkema1 librasteve: Are your problems macOS-related? Or on another system?
ab5tract librasteve: IRC jinx :) 21:27
librasteve ===> Staging Readline:ver<0.1.6>:auth<cpan:fooist> ===SORRY!=== Failed to get the directory contents of '/usr/local/opt/readline/lib': Failed to open dir: No such file or directory
on macOS
clarkema1 hah
same issue
looks like I found a tester ;)
ab5tract ohh
looks like its still expecting the old homebrew hierarchy 21:28
clarkema1 indeed
there's been a PR for that for over 2 years now
Today I'm also working on this: gist.github.com/clarkema/ee123f195...8420b134df 21:29
which is the same issue, but when using nix on macos
ab5tract ahh.... this makes me kind of sad. I was following the fork trail to understand how this module became abandoned and it was the awesome DrForr who originally contributed this module. He died several years back. 21:30
Miss that guy
clarkema1 oh, that is sad news 21:31
librasteve fwiw I think (due to prominence in repl) Readline should be a community module
clarkema1 I'm inclined to agree 21:32
ab5tract librasteve: agreed, thought it was in there already until this came up
clarkema1 librasteve: Not sent to any directories yet, but can you try `zef -v install github.com/clarkema/raku-readline.git`? 21:47
librasteve gets a lot farther gist.github.com/librasteve/f732141...2db1c38441 21:52
but still fails
clarkema1 interesting, looks like a test count issue 21:54
if you force the test does it actually work?
librasteve yep 21:55
(and repl is good) 21:56
clarkema1 well, that's progress
librasteve ++
gdown: I share your confusion on lookaround vs lookahead - the docs are LTA 21:57
gdown: I checked the design docs here github.com/Raku/old-design-docs/bl...-regex.pod 22:08
22:37 sena_kun left
clarkema1 librasteve: Can you remove and install again without forcing tests please? 22:39
librasteve ===> Installation [OK] 22:44
clarkema1 \m/
librasteve ++
22:47 jpn left
clarkema1 well then 23:03
I guess a) Readline:ver<0.1.7>:auth<zef:clarkema> is on zef now and b) it does indeed seem to be installed by default when you ask for `Readline` 23:04
which is a frankly terrifying way for a module system to behave, but there we are 23:05
I would still strongly favour that repo moving into community management 23:08
librasteve thanks for the fix 23:09
clarkema1 librasteve++ thanks for the help and testing 23:10
lizmat clarkema1: in Raku, you *can* ask for a specific auth / version of a module 23:12
librasteve gdown: the best I can see is that '<? .... >' is another form of lookahead which is a bit more concise and char class friendly
lizmat any type of production code *should* do that
clarkema1 I'm aware that you can, but I imagine most people don't when grabbing things like readline, or indeed fez itself, for random shell use 23:13
anyway, hopefully the world is a bit better for macos users now 23:14
librasteve so maybe ab5tract is right and we should ask the installer to choose the auth (for the top level) when there are more than one 23:15
lizmat I feel the installer should just fail if there's more than one auth
librasteve then that auth can pin deps as needed
lizmat but *that* would wreak havoc on any module formerly living in the p6c or CPAN ecosystem 23:16
librasteve well, then you need a way for adoption to be done and old auths to be sunsetted
ab5tract fail with a list of options, yes. 23:19
librasteve: fair breakdown
librasteve and with a -y flag for the Docker types 23:20
clarkema1 -y for --yolo 23:21
ab5tract in the meantime, we could at least do our own best practices and include the relevant auth tags in the message we print to "naked" repls 23:22
librasteve yawns
ab5tract librasteve: do you disagree with that approach? 23:24
gdown librasteve: it's weird that there are a couple places where <? ... > acts slightly differently though, maybe a bug? 23:32
for example: `say '333' ~~ m/\d+ <!before [\D]>/` => 「333」 but `say '333' ~~ m/\d+ <![\D]>/` => 「33」 23:34
23:44 lichtkind_ left
clarkema1 Right, that's enough for me for one day. Night all 23:46