00:00
yewscion left
|
|||
aruniecrisps | Thank you for the help! I'm currently playing around with the idea of making monad syntax in Raku and so I'm looking at the forgiven repo as a blueprint | 00:42 | |
guifa | m: enum Foo <a b c>; say Foo.^mro | 01:01 | |
camelia | ((Foo) (Int) (Cool) (Any) (Mu)) | ||
guifa | m: enum Foo <a b c>; say Foo.HOW | ||
camelia | Perl6::Metamodel::EnumHOW.new | ||
01:07
yewscion joined
01:10
AnaBanana joined
01:13
yewscion left
|
|||
guifa | hmmm | 01:13 | |
I'm trying to add a coerce target for an enum | |||
given, say | 01:22 | ||
enum Type <Question Answer Comment>; sub foo (Type() :$type) { ... } | |||
How could I enable calling with `foo :type<Question>` ? | 01:23 | ||
antononcube | Can use where in the sub's definition signature? | 01:24 | |
guifa | the where clause won't coerce the value | 01:25 | |
so COERCE gets called, but by default COERCE works on the value (0, 1, 2) not the identifier | |||
antononcube | I see. | 01:26 | |
01:29
AnaBanana left
|
|||
guifa | I mean I totally get I can just manually do stuff | 01:29 | |
but I'd rather handle it in the signature nicely if possible | 01:30 | ||
guifa is going to try to do an mDNS module | |||
it seems the problem is that the coerce HOW methods are applied after the trait | 01:36 | ||
aha got it | 01:45 | ||
multi sub trait_mod:<is> (::EnumType \enumerable, :$coerceable!) { enumerable.^add_multi_method('COERCE', anon sub COERCE (EnumType \SELF, Str \from) { SELF::.AT-KEY: from }) unless enumerable.HOW.^name eq 'Perl6::Metamodel::EnumHOW'} | 01:47 | ||
antononcube | 👍 | 01:48 | |
guifa | does mean I kinda want to use lc ones now | 01:51 | |
antononcube | Are you the only one who is going to read this code? | 01:52 | |
🙂 BTW, since you are record telling me to use kebab-case instead of camelCase, I feel I can justly ask: What's up with snake_case? (In your code.) | 01:54 | ||
01:54
Manifest0 left
|
|||
guifa | add_multi_method is a Raku HOW core method | 02:12 | |
so the idea is I can do Packet.new: :authoritative, :truncated, :want-recursive, :!recursive-available | |||
or | 02:13 | ||
:type<foo> | |||
I added a new multi candidate for the boolean ones | |||
antononcube | How about trait_mod ? | 02:17 | |
02:19
kylese left,
kylese joined
03:15
kylese left,
kylese joined
04:11
yewscion joined
04:15
yewscion left
04:34
yewscion joined
04:44
yewscion left
|
|||
guifa | same | 05:07 | |
the end result is you say | |||
enum Foo is enumerable <a b c>; | |||
err coerceable | |||
05:23
yewscion joined
05:27
yewscion left
|
|||
greenfork | [Coke]: I did exactly this :) I thought that maybe there's a better way to write in it repl without jumping between start/end of the line and classify seems great | 05:37 | |
timo: thank you for classify! I looked at it multiple times and it seemed like it doesn't do what I want. There's also categorize that I don't understand despite looking at it multiple times too | 05:38 | ||
I think I should make a cheat sheet for simple data transformations like list -> hashmap etc. | 05:39 | ||
In other languages there's a seemingly simpler alternative: there's a single "enumerable comprehension" function that specifies the final data structure | 05:41 | ||
Ruby: [%w[black tree], %w[yellow tree], %w[blue sky]].each_with_object({}) { |el, acc| acc[el[1]] ||= []; acc[el[1]].push(el[0]) } | 05:44 | ||
each_with_object({}) specifies `{}` | |||
Elixir (simpler example): for [v, k] <- [~w[black tree], ~w[blue sky]], into: %{}, do: {k, v} | 05:49 | ||
into: %{} specified `%{}` | |||
I was looking in Raku a similar idea but couldn't find it | |||
It is not bad but rather not obvious coming from other languages. A "general" solution seems easier than having to memorize specific functions that allow transitioning between different data structures | 05:50 | ||
07:57
Aedil joined
08:46
dakkar joined
08:56
yewscion joined
08:59
yewscion left
09:23
Sgeo left
09:27
Manifest0 joined
09:33
sena_kun joined
09:52
sena_kun left
10:34
traxex joined
|
|||
librasteve | greenfork: I will try to mirror your ruby example in raku: | 11:20 | |
Ruby: [%w[black tree], %w[yellow tree], %w[blue sky]].each_with_object({}) { |el, acc| acc[el[1]] ||= []; acc[el[1]].push(el[0]) } | |||
11:21
abraxxa-home joined
11:27
yewscion joined
11:29
yewscion left
11:35
yewscion joined
|
|||
Raku: my %h; [<black tree>, <yellow tree>, <blue sky>].map: { %h{.[1]}.push: .[0] } | 11:37 | ||
this is a slightly different take - since a raku Hash (%h) has a nice .push method that accumulates items as we need | 11:39 | ||
11:40
abraxxa-home left,
yewscion left
|
|||
I agree that .classify is a bit of a sledgehammer to crack this nut | 11:40 | ||
11:42
yewscion joined
11:46
yewscion left
12:07
zayd left
12:17
zayd joined
|
|||
Geth | ecosystem/main: 4484f6c967 | (Elizabeth Mattijsen)++ | META.list Remove Plosurin, looks like abandoned And no reaction from author |
14:38 | |
ecosystem/main: 995e27e153 | (Elizabeth Mattijsen)++ | META.list Remove modules by adaptiveoptics They appear abandoned and author doesn't respond |
14:52 | ||
ecosystem/main: 7c2d297497 | (Elizabeth Mattijsen)++ | META.list Remove ajs modules They will be migrated to Raku Community modules |
14:58 | ||
antononcube | @lizmat I wil put in my Raku Advent post draft within 5 hours. I assume that is a few hours before the automatic publishing. | 15:07 | |
lizmat | antononcube thanks! that's a relief to hear | 15:08 | |
antononcube | The post is 90% written -- I have to make coherent image links. (Always takes longer than expected.) | ||
lizmat | don't I know it :-) | 15:09 | |
antononcube | @lizmat Would be fine if the image are in "dark mode" ? | 15:13 | |
jdv | antononcube: did you get your dist fixed? | ||
lizmat | antononcube yes | ||
antononcube | @jdv Hmm.. I think it is just a library variable renaming. I think I did, but I have to experiment with the new version. | 15:14 | |
jdv | no, its a change in how the repl works | 15:17 | |
antononcube | Ok, I have misunderstood then. I can look into this more closely after 6-7 hours. | 15:18 | |
15:23
Sgeo joined
|
|||
tadzik | hmm. I know the best time to do this was like last year, but I reckon I should move my stuff to community modules :) | 15:36 | |
(or drop it entirely...) | |||
but I think at least some of it is useful | 15:37 | ||
lizmat | tadzik: if you could transfer the repos that you think are worth preserving, I'll make sure they get a nice new release as community moduoe | ||
*module | |||
tadzik starts with Acme::Meow | 15:38 | ||
15:44
GreaseMonkey left
|
|||
Geth | ecosystem/main: 5d177b246c | (Tadeusz Sośnierz)++ (committed using GitHub Web editor) | META.list Remove my modules They've been moved to raku-community-modules and/or are obsolete. |
15:44 | |
tadzik | I think I did this right | ||
lizmat | yeah, looks about ok :-) | 15:45 | |
15:53
yewscion joined
15:57
greaser|q joined
16:46
xinming left
17:11
MyNetAz left
17:26
MyNetAz joined
17:45
dakkar left
|
|||
librasteve | greenfork: if you are a purist and do not want to declare a lexical as your acc, maybe you would prefer this... | 17:48 | |
m: `[<black tree>, <yellow tree>, <blue sky>] andthen -> @_, %_={} { @_.map: { %_{.[1]}.push: .[0] }; %_ } andthen .say; | 17:49 | ||
evalable6 | (exit code 1) ===SORRY!=== Error while compilin… | ||
librasteve, Full output: gist.github.com/a0f9e565b8498f9bfd...a7c19055d7 | |||
Raku eval | Exit code: 1 ===SORRY!=== Error while compiling /home/glot/main.raku Bogus statement at /home/glot/main.raku:1 ------> <BOL>⏏``[<black tree>, <yellow tree>, <blue sk expecting any of: prefix statement list term | ||
librasteve | m: [<black tree>, <yellow tree>, <blue sky>] andthen -> @_, %_={} { @_.map: { %_{.[1]}.push: .[0] }; %_ } andthen .say; | ||
evalable6 | {sky => [blue], tree => [black yellow]} | ||
Raku eval | {sky => [blue], tree => [black yellow]} | ||
18:09
yewscion left
18:37
yewscion joined
18:39
sena_kun joined
18:45
yewscion left,
yewscion joined
18:46
zenmov left
19:07
Sampersand joined
|
|||
antononcube | @lizmat My Day 12 draft is completed. | 19:17 | |
lizmat | cool! | ||
antononcube | I did not schedule it. (I am not sure do I have the rights to do it.) | 19:18 | |
lizmat | ok, will do! | ||
thanks! | |||
antononcube | 👍 | ||
19:25
PipStuart joined
19:32
traxex left,
swaggboi left
19:36
traxex joined
|
|||
Geth | advent/main: 29b5639542 | (Elizabeth Mattijsen)++ (committed using GitHub Web editor) | raku-advent-2024/authors.md day 12 scheduled |
19:38 | |
antononcube | 🎉 | 19:41 | |
19:41
swaggboi joined
|
|||
lizmat | antononcube did some copy-editing as well, hope you don't mind | 19:42 | |
so you may want to double check if I didn't do an oopsie | 19:43 | ||
:-) | |||
antononcube | Thanks! I was just writing that I have to proofread the post again. | ||
I have an LLM prompt "CopyEdit", but using it usually takes me longer time, that "simple" proofreading/ | 19:45 | ||
19:46
Sampersand left
19:47
yewscion left
19:50
Sampersand joined
|
|||
Geth | ecosystem/main: 7d7711bce6 | (Elizabeth Mattijsen)++ | META.list Remove jnthn's modules They are being migrated to Raku community modules |
19:53 | |
19:57
yewscion joined
20:07
Sampersand left
|
|||
greenfork | @librasteve interesting! My point about avoiding a lexical variable is to type it in repl more easily. So although there's a purist in me, I for the love of God would not remember such incantation :) | 20:07 | |
Raku: my %h; [<black tree>, <yellow tree>, <blue sky>].map: { %h{.[1]}.push: .[0] } | 20:09 | ||
That is very close. Interesting use of dots in .[1] | 20:10 | ||
20:13
greaser|q left,
greaser|q joined,
greaser|q is now known as GreaseMonkey,
yewscion left
20:14
swaggboi left
20:17
yewscion joined
20:21
kjp left
20:27
Sampersand joined
20:41
Aedil left
20:58
Sampersand left
|
|||
librasteve | yeah - the andthen is a bit of an acquired taste ... another way to write that is as an sub declaration and then to call it on your data: | 21:07 | |
my &fn = -> @_, %_={} { @_.map: { %_{.[1]}.push: .[0] }; %_ } | 21:08 | ||
say fn( [<black tree>, <yellow tree>, <blue sky>] ); | 21:09 | ||
another way to write the function is: | 21:10 | ||
my &fn = -> @el, %acc={} { @el.map: { %acc{.[1]}.push: .[0] }; %acc }; | |||
which is familiar from the ruby hopefully... | |||
21:22
swaggboi joined
22:38
Sampersand joined
23:14
sena_kun left
23:17
Sampersand left
23:21
yewscion left
23:37
AlexDaniel joined
23:46
unicodable6 joined
23:55
AlexDaniel left,
AlexDaniel joined
|