🦋 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 inspection is getting closer to beta. If you're a beginner, you can also check out the #raku-beginner channel!
Set by lizmat on 25 August 2021.
Geth vim-raku: sjn++ created pull request #36:
Ignore generated doc/tags
07:42
grondilu m: class { has %.h handles <AT-KEY>; multi method foo($x where (%!h{$x}:exists)) { self{$x} } }.new(:h{ foo => "bar" }).foo("foo") 09:06
camelia ( no output )
grondilu m: class { has %.h handles <AT-KEY>; multi method foo($x where (self{$x}:exists)) { self{$x} } }.new(:h{ foo => "bar" }).foo("foo")
camelia Cannot resolve caller foo(<anon|1>.new(h => {:...: foo); none of these signatures matches:
(<anon|1>: $x where { ... }, *%_)
in block <unit> at <tmp> line 1
grondilu can't I use self in a signature? 09:07
m: class { has $.m; multi method foo($x where $x %% self.m) {}}
camelia ( no output )
grondilu m: class { has $.m; multi method foo($x where $x %% self.m) { $x / $!m }}.new(:m(3)).foo(12).say 09:08
camelia 4
Voldenet grondilu: you can use self as you wanted, but in :exists case you need EXISTS-KEY handled 12:06
m: class { has %.h handles <AT-KEY EXISTS-KEY>; multi method foo($x where (self{$x}:exists)) { self{$x} } }.new(:h{ foo => "bar" }).foo("foo")
camelia ( no output )
Voldenet you may also want STORE handled
Xliff m: role FontWidget { }; multi sub trait_mod:<is> (Attribute \a, :$font!) { a does FontWidget }; class A { has $.aa }; trait_mod:<is>(A.^attributes[0], :font); 12:58
camelia ( no output )
grondilu Voldenet: noted, thanks 14:10
Xliff Um. rakubrew.org is busted. 16:39
Please someone say it isn't so!
Altai-man Xliff, alas, 500 error. 16:46
patrickb, ping?
[Coke] console says crbug/1173575, which SO says might just be a connectivity error. (maybe a cloudflare issue?) 16:48
Bscan🍺 Coke, I'm on the Discord side, so I cant see <#538420565980086273>docs. Quick question though: is there a JSON version of the docs? If so, I'd like to incorporate it into the Raku Navigator Language Server. 17:58
Xliff Are there recent binary packages for Rakudo? 18:11
If so, where can I get them? Ubuntu impish has 2020.12
I need something much closer to 2022.04
lizmat Xliff: El_Che's packages ? 18:32
nxadm.github.io/rakudo-pkg/ 18:33
Xliff lizmat++ # Thanks! 18:39
p6steve i'm thinking about Dan::Polars - raku polars <-> rust polars <-> arrow2 ... this implies getting raku <-> rust working ... is there any prior art I can "borrow"? 19:07
[coda: does NativeCall use FFI? if so -- would this guide doc.rust-lang.org/nomicon/ffi.html hold for the rust side of things?] 19:09
please ;-) 19:16
lizmat nine ^^ ?? 19:28
grondilu m: role R[Hash $h] { has %.h = %$h }; say class :: does R[%(foo => "bar")] {}.new.h 19:41
camelia {foo => bar}
grondilu and yet: 19:42
m: role R[Hash $h] { has %.h = %$h }; my $h = %(foo => "bar"); say class :: does R[$h] {}.new.h
camelia ===SORRY!=== Error while compiling <tmp>
No appropriate parametric role variant available for 'R':
Cannot resolve caller (<anon|1>, Any:U); none of these signatures matches:
(::$?CLASS ::::?CLASS Mu, Hash $h)
at <tmp>:1
grondilu what is different in these two lines?
p6steve apt-get install libperl-dev -y \ 19:45
&& zef install Inline::Perl5 \
&& cpan App::cpanminus \
&& cpanm FFI::Platypus FFI::Platypus::Lang::Rust
grondilu m: role R[Hash $h] { has %.h = %$h }; my $h = %(foo => "bar"); say class :: does R[$h.Hash] {}.new.h
camelia {}
p6steve ^^^ yikes - this worked(!) - thinking perl5 maybe adequate route to rust (comments / alternatives welcome please) 19:46
grondilu is it too much to put a hash as a parameter for a role or something?
tonyo can you rephrase that q p6steve ? 19:47
tellable6 2022-05-02T13:10:00Z #raku-dev <carlmasak> tonyo the thing that would make me consider Haskell's package management a significant step up from Go's isn't some technicalities around go.mod, but how well it solves the "stable dependencies" problem.
tonyo .tell carlmasak agreed (re:haskell's stability in dependencies) 19:48
tellable6 tonyo, I'll pass your message to carlmasak
Voldenet m: role R[Hash $h] { has %.h = %$h }; my $h = %(foo => "bar"); say (class :: {}.new but R[$h]).h 19:51
camelia {foo => bar}
Voldenet role R[$h] { has $.h = $h }; my Hash $h = %(foo => "bar"); say class :: does R[BEGIN { say $h; $h }] {}.new.h 19:52
evalable6 (Hash)
(Hash)
p6steve tonyo: sure - I want to write a new raku module that implements raku Dan (github.com/p6steve/raku-Dan) in the fast Apache Arrow2 library - since Dan is a raku alternative to Pandas/Polars Series & DataFrames, I think that it would be less work to interface Dan to Polars (which is implemented in Rust) 19:53
grondilu Voldenet: oh yeah, the parameter has to be defined at class composition time or something. of course. 19:54
Voldenet I suspect that's the case
p6steve soooo - my question is "are there any examples of interfacing raku to rust - for example via FFI?" and "does the info at guide doc.rust-lang.org/nomicon/ffi.html fit that from the rust side?" 19:55
p6steve appreciate any guidance 19:58
nine If that Rust library exposes a C interface, I can imagine that just working as is via NativeCall 20:04
p6steve nine: tx! I suppose my base ignorance is that I do not know if NativeCall does FFI, or whether that matters? 20:08
nine What do you mean with "FFI"? 20:11
p6steve nine: I mean this --> en.wikipedia.org/wiki/Foreign_func..._interface 20:15
nine: (but I wonder if this is just what raku does anyhow - and thus I am confused) 20:16
nine That's why the question confuses me. Of course NativeCall is a foreign function interface. It is how you call native (i.e. non-Raku) functions from Raku 20:17
[Coke] bscan: what would a json version of the docs look like? 20:19
Is there some object standard for that? 20:20
p6steve haha - well the Platypus I shared above has a rust example like this: 20:21
1 #![crate_type = "dylib"]
2
3 // compile with: rustc add.rs
4
5 #[no_mangle]
6 pub extern "C" fn add(a:i32, b:i32) -> i32 {
7 a+b
8 }
this makes 'libadd.so' 20:22
so I will just go for that with NativeCall ... and see how I get on! 20:23
I [almost] want to use P5 Platypus as a go-between ... but will resist the urge to go too fast and loose 20:26
nine: vielen dank 20:30
melezhik . 20:47
Xliff p6steve: As long as your library is a valid .so, NativeCall will run it. 21:41
So for that particular function it would be... "use NativeCall; sub add (int32, int32) returns int32 is native(add) { * } 21:42
Voldenet I don't think you need (add) in that case 21:45
melezhik I am thinking to create a badge for Sparky CI builds, any thought how can I do it using cro? should I use static files or generate SVG on the fly? 21:57
p6steve Xliff: Cannot resolve caller guess_library_name(Nil:U, Nil:U); none of these signatures matches: ... suppose I need to "use" libadd.so somehow? 22:03
Xliff: Cannot locate native library 'libadd.so': libadd.so: cannot open shared object file: No such file or directory 22:05
^^ this with native('add') 22:06
Xliff: 1 use NativeCall; sub add (int32, int32) returns int32 is native('add') { * }; say add(1, 2); 22:09
Xliff: 3
Xliff: (had to cp libadd.so /usr/lib) 22:10
Xliff: cool - thanks!!
Voldenet p6steve: you don't need to have libadd.so in /usr/lib - you can provide full path iirc 22:42
> The native trait accepts the library name, the full path, or a subroutine returning either of the two. When using the library name, the name is assumed to be prepended with lib and appended with .so (or just appended with .dll on Windows), and will be searched for in the paths in the LD_LIBRARY_PATH (PATH on Windows) environment variable. 22:43