🦋 Welcome to Raku! raku.org/ | evalbot usage: 'p6: say 3;' or /msg camelia p6: ... | irclog: colabti.org/irclogger/irclogger_log/raku
Set by ChanServ on 14 October 2019.
affaf Hey dudes. Quick question. 04:30
```
```sub foo(Str $s) { "" };say "this shouldn't run";if (0 == 0){ my Int $x = foo(""); say $x}``` should not type check but why does this work?
Ugh here's a hastebin link hasteb.in/vetoqowe.pl 04:31
affaf As in I still get the print. 04:45
timotimo m: sub foo(Str $s --> "") {}; say foo 05:15
camelia 5===SORRY!5=== Error while compiling <tmp>
Calling foo() will never work with declared signature (Str $s --> "")
at <tmp>:1
------> 3sub foo(Str $s --> "") {}; say 7⏏5foo
timotimo m: sub foo(Str $s --> "") {}; say foo("")
camelia
timotimo m: sub foo(Str $s --> "") {}; my Int $a = foo("")
camelia Type check failed in assignment to $a; expected Int but got Str ("")
in block <unit> at <tmp> line 1
timotimo m: sub foo(Str $s --> "") {}; my Int $a = foo(""); say "never runs"
camelia Type check failed in assignment to $a; expected Int but got Str ("")
in block <unit> at <tmp> line 1
timotimo m: sub foo(Str $s --> "") {}; say "runs"; my Int $a = foo(""); say "never runs"
camelia runs
Type check failed in assignment to $a; expected Int but got Str ("")
in block <unit> at <tmp> line 1
timotimo that's runtime, too
samebchase- Hello, Say I have a hash %h with many keys, and now I want a smaller hash with just the keys a, b. I know I can do %h<a b>:p, but that gives me a list. How do I get a smaller "subset" hash? 07:36
samebchase- I would imagine that this is not an encouraged workflow because we don't have structural-sharing... It would allocate a whole new map. 07:52
MasterDuke m: my %a = %(:1a, :2b, :3c); my %b = %a<b c>:p; dd %a; dd %b 08:02
camelia Hash %a = {:a(1), :b(2), :c(3)}
Hash %b = {:b(2), :c(3)}
samebchase- woah, let me try that out. The documentation says that "The adverb :p returns a Pair or a List of Pair instead of just the value." 08:08
So it would need to be assigned to a new hash
elcaro Another useful feature of the `:p` on hash slices is that it will "collapse" undefined values 08:23
so oyu can fearlessly give a list of keys that may or may not be in the original hash
m: my %h = (:1a :2b :4d); my @k = <a b c>; say %h{@k}; say %h{@k}:p
camelia (1 2 (Any))
(a => 1 b => 2)
elcaro similar to doing a set intersection 08:25
m: say set(<a b d>) ∩ set(<a b c>)
camelia Set(a b)
samebchase- thank you MasterDuke and elcaro! 11:13
MasterDuke np 11:19
suman github.com/Raku/problem-solving/bl...to-Raku.md 11:28
uzl[m] .seen jmerelo 11:47
tellable6 uzl[m], I saw jmerelo 2020-05-28T10:07:04Z in #raku-dev: <JJMerelo> jnthn by all means.
uzl[m] .tell jmerelo I think some doc issues that were addressed by respective PRs and could thus be closed. From the top of my head: github.com/Raku/doc/issues/3389 , github.com/Raku/doc/issues/3308 11:50
tellable6 uzl[m], I'll pass your message to JJMerelo
[Coke] I get "type check failed" 13:19
(the code in the bin said "if true, run this code"... so yes, it was going to run. :) 13:21
raku-bridge <Tilwa> I found a broken link on raku.org/community/ : the smoke testing links to smoke.perl6.org/ which is the default nginx page. Is there a working page somewhere or should it be removed ? 14:41
jdv79 Tilwa: there's a link at the bottom of hte page about how to contrib/fix that 15:15
though what the fix would be is unclear
dotdotdot Well, I'll open a github issue later then. Thanks! 15:16
jdv79 i guess that was zoffix so maybe just remove that section...? 15:17
dotdotdot Maybe it could link to rakudist instead? dunno 15:21
poohman hi 15:30
was trying to use the module XML::Class and was aiming at using a method called from-xml 15:31
it throws an error saying none of the signatures match 15:32
what does the second argument in the signature below stand for
?
(XML::Class:U: Str $xml, *%_ --> XML::Class)
just to be sure that I was making no typos I generated an xml string using the to-xml method and passed that 15:33
but got the same error
elcaro this is a class method, as the first parameter is an undefined XML::Class. the second is the $xml string, the third just stores and pairs/named args in the %_ hash 15:34
poohman are there three arguments or two? 15:35
elcaro so it looks like it would just be XML::Class.from-xml('<...>')
well.. it's a method, so "first" is the invocant
poohman and what does *%_ mean? 15:36
elcaro it's just an anonymous hash... similar to how we have $_
poohman ok
elcaro m: sub foo($bar, *%_) {say %_}; foo('one', two => 2, :!three) 15:37
camelia {three => False, two => 2}
elcaro just a way to capture any named args
m: sub foo($bar, *%_) {say %_<three>}; foo('one', two => 2, :!three) 15:38
camelia False
poohman ok
poohman thanks elcaro 15:41
elcaro np 15:45
I've not used to module before.. so i'm not sure if i've given correct info 15:46
poohman one more question - XML::Class:U - what does the U here stand for?? undefined? 15:49
MasterDuke yeah, the type object 15:51
poohman ah 15:52
I was all these days forgetting to instantiate it and when I finally remember to do it
I get this
so I dont use new?? 15:53
MasterDuke yeah, then it's like a "class" or "static" method in other languages 15:56
poohman but I dont understand how one would pull the data into a type object - wont I need a instamtiated object to assign the data I deserialise from the xml 16:07
timotimo classes with static data store them in the lexical scope of the class body 16:08
poohman how would I be able to access them - could you give a smll example 16:09
timotimo you'd need an accessor method
m: class Flob { has $.attribute; my $static-one; my $static-two; method access-one is rw { $static-one }; method read-two { $static-two } }; Flob.new(attribute => 1).raku.say; Flob.access-one = 99; say Flob.access-one; 16:10
camelia Flob.new(attribute => 1)
99
timotimo m: class Flob { has $.attribute; my $static-one; my $static-two; method access-one is rw { $static-one }; method read-two { $static-two } }; my $inst-one = Flob.new; $inst-one.access-one = 99; say Flob.access-one;
camelia 99
poohman ok - let me look at the example again - maybe I missed the static member part of it 16:12
timotimo i didn't read further up, so i may have missed something 16:13
poohman ok - I see some light now - thanks - need to take a break 16:21
seems like a lot of MOP there
mahafyi i feel somewhat ready to start trying somethings with raku. i was looking at web modules, i can undertsnad the cro architecture but can't do a react redux site. But i understand Uzu, and the template6 / mustache. i am planning to start directly writing html files from raku, with inline javascript as needed. any guidance on starting website with 17:19
raku?
timotimo the reason why cro uses react/redux is just that it's pleasant to use 17:33
cro can work with any framework as well as frameworkless; there's a template language now, too
timotimo i haven't looked at uzu at all yet 17:35
timotimo oh, and of course cro can use any template engine that spits out any kind of data that is to be delivered to the client 17:35
as well as just writing your html in your code if you like 17:36
HTML::Tag: say HTML::Tag::p.new(:text('This is my paragraph'), :class('pretty')).render; 17:37
Typesafe::HTML: my $html = HTML.new('<p>this will not be quoted</p>'); $html ~= '<p>this will</p>'; 17:38
modules.raku.org/dist/HTML::BoreDO...an:ALLSOPP here you nest calls to a sub called "h" 17:39
modules.raku.org/dist/HTML::Lazy:cpan:SAMGWISE - haven't looked at this one at all yet
mahafyi timotimo : ah ok. so we can just use the cro pipelines to generate content on the flow by directly writing the html files needed. we can make the grammars needed to build links across all sitemap pages. I hadnt seen the Typesafe::HTML :) 17:40
as far as Uzu goes i was thinking just to start with an apache httpd instead for web server. as it provides authentication for users out of the box. 17:41
timotimo well, don't have to "write files" really 17:42
mahafyi how will the user have a html file in the web server then? 17:43
timotimo there doesn't have to be a file for some html to be served 17:44
the server can literally make shit up :)
mahafyi i see. i didn't know about that.
timotimo having to have one file correspond to one URL is probably a thing you are used to from coding with php or cgi scripts directly 17:45
over there you'd often put a .htaccess file that rewrites URLs 17:46
but "web applications" and "web frameworks" just grab the whole request, so you can decide on your owh whether you look at the filesystem, at a database, at a random number generator, at the stars, etc
mahafyi wow. look like i need to understand this whole thing afresh. 17:48
Xliff \o 18:00
I'm tryint to print color sequences to the console. I'm doing something like this...
m: print "\033Hello!\033"
camelia ␀33Hello!␀33
Xliff So only the "\0" part is being recognized. What's the proper way to implement this? 18:01
( I hope it isn't chr.... }
mahafyi ah so that how things like Uzu does its 'live reloads' etc, where any content changed in the 'watch' paths immediately shows up in browser.i was wondering about that 18:02
Xliff Well... "{ chr(27) }" but is more verbose than I'd like. 18:03
\o ctilmes!
[Coke] Xliff: This answers a different question, but have you seen: github.com/tadzik/Terminal-ANSIColor 18:09
Xliff I've not looked deeply into it, no. 18:10
Oh, LOL!\
\e... much better! :)
[Coke] m: print "\0d12" 18:11
camelia ␀d12
[Coke] (nope)
m: print "\c[33]" 18:13
camelia !
[Coke] m: print "\x033"
camelia 3
timotimo m: print "\o033 18:33
camelia 5===SORRY!5=== Error while compiling <tmp>
Unable to parse expression in double quotes; couldn't find final '"' (corresponding starter was at line 1)
at <tmp>:1
------> 3print "\o0337⏏5<EOL>
expecting any of:
argument l…
timotimo m: print "\o033"
camelia
[Coke] m: "\o033".uninames.say 18:40
camelia (<control-001B>)
[Coke] timotimo++
timotimo greppable6: \\0\d\d 18:41
greppable6 timotimo, 175 lines, 32 modules: gist.github.com/8d0ca6466379338db3...3ce28ce9c7
timotimo not going through all of that now 18:49
the first few i looked at were in readme and pod
mahafyi so cro istelf is a webserver, doesn't need something like apache http to serve up web content. and can do secure https connections as well.. 19:36
timotimo usually you'd want to have an nginx in front, much like you would with other web frameworks 19:56
let the webserver handle TLS and load balancing, and static file hosting is something nginx is quite fast at 19:57
mahafyi oh ok. just working thru the cro examples now. 20:03
but in the first cro example localhost:20000 says HELLO, and i can't find the word HELLO and how it is served up anywhere in the dir (that was stubbed) files, except there is some binary file that matches. 20:08
timotimo it's not under lib/Routes.rakumod (or .pm6 or whatever)? 20:12
mahafyi pastebin.com/cx2DHFGR this is all i see 20:15
so it shows as a binary file match in lib/.precomp 20:16
timotimo well, what is in lib/Routes.pm6? 20:19
mahafyi oh so sorry, i did a case sensitive grep forgot the -i flag. 20:20
timotimo ah :) 20:21
it happens
moon-child I've been playing with the fancy superscripts 20:22
5⁶⁷ is the same as 5 ** 67 -- well and good
plain ⁶ is the same as 6. That means that ⁶⁷⁸ is the same as 6 ** 78, which feels inconsistent and not obvious 20:23
timotimo yeah
m: say 5⁶⁷5⁶
camelia 5===SORRY!5=== Error while compiling <tmp>
Two terms in a row
at <tmp>:1
------> 3say 5⁶⁷7⏏055⁶
expecting any of:
infix
infix stopper
postfix
statement end
statement modifie…
moon-child I think it might be better to straight up outlaw leading superscript. But if not that, then ⁶⁷⁸ should be 678 20:25
timotimo i'd only outlaw mixing the interpretation of superscript as superscript after a superscript digit 20:29
mahafyi timotimo : thanks - here is a first html page (i slurped a file i downloaded from w3 css) pasteboard.co/JaFe8b7.png 20:32
i suppose its singularly uninteresting to anyone, but i am very happy lol 20:33
mahafyi is there any reason to choose ngnix over apache http (since i have setup apache only so far) 20:42
moon-child timotimo: hmmm. That's probably reasonable 20:44
mahafyi: nginx is faster and simpler. But apache is a totally fine choice. And it shouldn't be hard to switch later on, if you need to
mahafyi moon-child ty 20:45
mahafyi ok first onto learning Cro::HTTP::Router :) 20:52
moon-child trying to install IO::Socket::Async::SSL gives 'Could not find OpenSSL in: (bunch of paths)' I have openssl installed (obviously). How do I tell the package about it? 21:12
ToddAndMargo Hi All. Over on github.com/tadzik/perl6-Config-INI...ter/README What does he mean "For example usage, see SYNOPSIS in the Pod"? What is a Pod and where do I fid it? 23:08
timotimo github.com/tadzik/perl6-Config-INI...INI.pm#L45 23:09
"POD" used to stand for "plain old documentation" i think? it's a more complex format of comments with things like sections, links between things, formatting, etc 23:10
and it usually lives in a perl module file, usually at the end
raku has a format that's just called "Pod" rather than it being an abbreviation 23:11
it's the format in which the whole raku documentation site's content is written
ToddAndMargo Would that be in his code section? 23:12
Found it. github.com/tadzik/perl6-Config-INI...fig/INI.pm starts at line 45. Thank you! 23:13