🦋 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.
japhb "Zipping" conceptually has a reasonable default realization that makes sense as a "simplest version" of its general operation. What would be your expected default realization for "operator reversing"? 00:05
habere-et-disper I don't know. I hadn't thought about it as operator reversing and as just reversing. Your terminology is helpful (I see no official docs on R yet?). Thank you japhb! 00:13
guifa_ habere-et-disper docs.raku.org/language/operators#i...taoperator 00:14
SmokeMachine does ae think somenthig like this is interesting for Raku? usercontent.irccloud-cdn.com/file/...6%402x.png 08:07
Nemokosch what is ae? 08:09
SmokeMachine sorry? 08:10
Nemokosch > does ae think somenthig like this is interesting for Raku 08:11
exactly... sorry? 😄
SmokeMachine sorry... my machine is not working very well... my intention was to write: `Does anyone think something like this is interesting for Raku` 08:12
for some reason `anyone` become `ae`... 08:13
Kaiepi what is it exactly? port of Maybe? 08:14
SmokeMachine Kaiepi: my intention is a port of functors, applicatives and monads (I'm trying to study it) and some useful monads, like Maybe... 08:15
Kaiepi you're gonna run into trouble eventually without higher kinded generics for niceties like MaybeT 08:16
SmokeMachine currently it's Maybe[T]...
Kaiepi the monad transformer 08:17
SmokeMachine Kaiepi: I haven't step there yet... :) (sorry, I don't know what's that about)
I think this is a bit better (explicit return type will probably be required in the next version): usercontent.irccloud-cdn.com/file/...7%402x.png 08:19
Kaiepi Semigroup and Monoid would be nice 08:22
Nemokosch why would it? 08:29
SmokeMachine maybe this would also be interesting? usercontent.irccloud-cdn.com/file/...2%402x.png 08:35
Voldenet it's a good idea, but in practice needs really good language support 09:11
otherwise it's either slow or painful to use 09:12
btw, currying already exists 09:16
m: my &bla = * / *; &bla = &bla.assuming(*, 2); say &bla(10)
camelia 5
Voldenet ofc, Maybe[T] is useful in some cases, but in most of those you can simply use one-element lists for everything 09:46
e.g. 09:47
m: sub split-email { $^optional-email.map: { .contains("@") ?? .split("@").tail !! |() } }; say ("abc@def.ghi").&split-email;
camelia (def.ghi)
Nemokosch Well, what is it useful for? 09:48
I feel like a good share of this stuff comes from insisting on a type system
Voldenet Building enormously long chains of maybe-based calls
SmokeMachine Voldenet: I tried simply using .assuming, but I found using curry implicitly easier...
Voldenet well, .assuming had one gigantic performance problem in the past 09:49
`&f.assuming(*, 2);` was slower than `{ &f($^a, 2) }` 09:50
iirc rakuast is doing something about it
Nemokosch that's indeed quite a problem...
why `&`f, tho 09:52
is that a call or not?
SmokeMachine about the 1 element list, doing that that way, you need to expect the list, right? isn't the monad/bind advantage that you can use functions that expect only the value and return a monad? (I'm still studying it... I may have misunderstood) 09:53
(I may have misunderstood it) 09:54
Voldenet (it was just an example, actual currying would require capturing original function and creating new one) 09:55
m: my &bla = * / *; &bla = -> &f { -> $x { &f($x, 2); } }(&bla); say &bla(10); say now - BEGIN now 09:56
camelia 5
0.016728923
Voldenet m: my &bla = * / *; &bla = &bla.assuming(*, 2); say &bla(10); say now - BEGIN now
camelia 5
0.079365177
Voldenet ye, still painfully slow
SmokeMachine: Not quite, it's the monad that decides whether the function will be applied or not, so you first have to convert value into a monad to call a function 09:57
SmokeMachine yes, but the function itself receives the value, not the monad, right? that the reason for the bind, right? 09:58
Voldenet Yes
consider this:
m: sub maybe { (try &^f($^a)) // Any }; sub split-email { $^email.split("@")[1..*].tail }; say Any.&maybe(&split-email);
camelia (Any)
SmokeMachine like, on my example, split-email and split-domain receives a Str, and not a Maybe[Str] 09:59
Voldenet you can also do `$^a ?? &^f($^a) !! Any` 10:00
SmokeMachine yes, but I'll need to do that on every function I'd bind in sequence... with Maybe and bind it will just not call the function, right? 10:01
El_Che (not that someone is asking, but you can have more @ if quoted, or no @ at all, eg using !) 10:03
SmokeMachine El_Che: sorry, I didn't get it 10:04
I was also wondering if containers could be Monads... Positional already kind of is, right?
El_Che SmokeMachine: being pedanrtic about sub split-email { $^email.split("@")[1..*].tail } :)
SmokeMachine El_Che: :) 10:05
Voldenet SmokeMachine: also correct, that's why I said that it has its uses
still: Maybe(Any).map(&split-email).map(&split-domain) isn't much better 10:07
and using an operator for this is going to introduce some weird-looking syntax 10:08
SmokeMachine I thought this would work... but it didn't: usercontent.irccloud-cdn.com/file/...9%402x.png 10:16
my bad, I meant this: usercontent.irccloud-cdn.com/file/...9%402x.png 10:18
Voldenet either way, it introduces weird style 10:34
Nemokosch what doesn't work about it? 10:38
seems to me that it did exactly what one would expect 10:39
Voldenet …or you could just skip all that nonsense and get to the point 10:51
m: sub split-email(Str:D $e) { $e.split("@")[1..*].tail }; sub split-domain(Str:D $d) { $d.split(".").head }; say try { "abc".&split-email.&split-domain };
camelia Nil
Nemokosch aand it would still be nil 😄 10:54
Voldenet but in this case, it's possible to do this: 10:57
sub split-email(Str:D $e) { $e.split("@")[1..*].tail }; sub split-domain(Str:D $d) { fail "domain has no dot" unless $d.contains("."); $d.split(".").head }; say try { "abc@def".&split-email.&split-domain } // $!;
evalable6 domain has no dot
in sub split-domain at /tmp/L3gDILjdSj line 1
in block <unit> at /tmp/L3gDILjdSj line 1
Nemokosch what is the significant difference? 10:58
Voldenet you can know why did you get an empty result… ;) 10:59
Nemokosch I mean... actually not convinced by that, lol 11:01
especially regarding the split-email 11:02
Voldenet …uh uh :) 11:05
`Type check failed in binding to parameter '$d'; expected Str but got Nil (Nil)` is telling you why things failed :)
SmokeMachine But a Either would also do that, right?! 11:06
Voldenet yes, but it'd be another layer of pain, because now you'd have to convert any non-either subs to new conventions… and you have no language support 11:11
Nemokosch split-email doesn't really show why you got Nil in the first place 11:25
Voldenet it might lack a few checks… 11:27
…probably all of them
SmokeMachine usercontent.irccloud-cdn.com/file/...1%402x.png 11:30
better: usercontent.irccloud-cdn.com/file/...1%402x.png 11:33
Voldenet there's one problem with this - you have to type Result and Error separately 11:50
Voldenet I bet you can add a coercer for this 11:50
so the code can become `… –> Either[Str, Str] { $email.contains("@") ?? ok $email.split("@").tail !! error "Invalid email" }` 11:51
or `–> Either[Str, Str]()` 11:53
SmokeMachine yes, I'm planing doing that... `-> Either[Str, Str]() { Bool.pick ?? right "ok" !! left "error" }` would coerce and also `-> Maybe[Int]() { nothing }` 11:59
but I haven't done that yet... 12:00
Nemokosch something else 12:08
what gets passed to <?{}> in regex?
SmokeMachine what am I doing wrong? 12:24
m: role Left[$, $] { ... }; role Either[::L = Any, ::R = Any] { multi method COERCE(Left[L, Any] (L :$value)) { Left[L, R].new: :$value } }; role Left[::L = Any, ::R = Any] does Either[L, R] { has L $.value; }; my Either[Str, Str]() $a = Left[Str, Any].new: :value("error")
camelia Type check failed in assignment to $!value; expected L but got Str ("error")
in method COERCE at <tmp> line 1
in block <unit> at <tmp> line 1
SmokeMachine m: say "abc" ~~ /.*<?{ False }>/ 12:25
camelia Nil
SmokeMachine m: say "abc" ~~ /.*<?{ 1 == 1 }>/
camelia 「abc」
SmokeMachine Nemokosch: you mean like this 👆? 12:27
tellable6 SmokeMachine, I'll pass your message to Nemokosch
SmokeMachine m: role Left[$, $] { ... }; role Either[::L = Any, ::R = Any] { multi method COERCE(Left[L, Any] (L :$value)) { Left[L, R].new: :$value } }; role Left[::L = Any, ::R = Any] does Either[L, R] { has $.value; }; my Either[Str, Str]() $a = Left[Str, Any].new: :value("error") # worst 12:33
camelia Impossible coercion from 'Left[Str,Any]' into 'Either[Str,Str]': method COERCE returned an instance of Left[L,R]
in block <unit> at <tmp> line 1
SmokeMachine should this be working? 👆
m: role Left[$, $] { ... }; role Either[::L = Any, ::R = Any] { multi method COERCE(Left[L, Any] (L :$value)) { Left[L.WHAT, R.WHAT].new: :$value } }; role Left[::L = Any, ::R = Any] does Either[L, R] { has $.value; }; my Either[Str, Str]() $a = Left[Str, Any].new: :value("error") # this seems to work 12:34
camelia ( no output )
SmokeMachine m: role Either[::L = Any, ::R = Any] {}; role Left[::L = Any, ::R = Any] does Either[L, R] { has L $.value; }; sub a(-->Either[Str, Str]()) { Left[Str, Str].new: :value("error") }; say a # Should it be trying to coerce??? Left[Str, Str] does Either[Str, Str] 12:54
camelia Left[Str,Str].new(value => "error")
SmokeMachine oh! it isn't working on mi machine... let me update Raku...
Nemokosch > Nemokosch: you mean like this 👆? 13:03
yes, I mean like that 🙂
SmokeMachine Voldenet: now it works: usercontent.irccloud-cdn.com/file/...3%402x.png 13:10
Voldenet regarding Either, it's nice to have such a feature that can coerce Either[L, R] into T when L is T or R is T 13:14
SmokeMachine And maybe Failure/Exception into Left... 13:17
Voldenet doc.rust-lang.org/std/result/enum.Result.html 13:18
[Coke] docs.raku.org/language/operators#i...taoperator (Docs for R) 14:00
[Coke] doc visit today. They couldn't do my blood draw because they couldn't get into my chart.... because they were rolling out a new version of the software, and someone 10 states away was "in" my chart somehow. The future sucks! :) 18:38
[Coke] yawns. 18:45
SmokeMachine How my functional suiting is going: github.com/FCO/raku-functional/blo...ample.raku 19:42
Nemokosch seems rather sadistic ngl 19:43
iirc Erlang also wasn't this dogmatic 19:45
[Coke] someone have some shorthand for turning my @a=<a b c d> into my %h<a><b><c><d>=True ? 19:51
gfldex m: my @a=<a b c d>; my %h{||@a} = True; dd %h; 19:52
camelia Odd number of elements found where hash initializer expected:
Only saw: Bool::True
in block <unit> at <tmp> line 1
gfldex my @a=<a b c d>; (my %h){||@a} = True; dd %h; 19:53
evalable6 Hash %h = {:a(Bool::True), :b(Any), :c(Any), :d(Any)}
gfldex m: use v6.*; my @a=<a b c d>; (my %h){||@a} = True; dd %h; 19:54
camelia Hash %h = {:a(${:b(${:c(${:d(Bool::True)})})})}
gfldex [Coke]: ^^^ yes but v6.*
SmokeMachine: tyvm, I learned something from github.com/FCO/raku-functional/blo...akumod#L21 19:58
Nemokosch and what was the new thing? 20:06
damn, I will learn the names eventually 20:07
gfldex is the one who always blogs a little... 20:08
gfldex I did not realise that I can chain methods calls after a call to `.none` and friends.` 20:19
Nemokosch oh 20:20
well I don't even know if I knew it or not xD
gfldex I used FALLBACK in the same way as Junction does (or could, without -O) but didn't make the connection to `.none`, which I used a lot. 20:22
altreus™ Anyone know how to configure raku.vim to fold POD blocks? If I let raku_fold=1, then it just folds my entire class and doesn't seem to have multiple levels of fold ... 21:21
Looks like I tried to figure it out a year ago github.com/Raku/vim-raku/issues/32 21:27
Geth ecosystem: 598b19565d | (Richard Hainsworth)++ (committed using GitHub Web editor) | META.list
Update META.list

Migrating finanalyst/Collection to fez
23:31