Skip to content

Instantly share code, notes, and snippets.

View Xliff's full-sized avatar
🏠
Working from home

Xliff Xliff

🏠
Working from home
View GitHub Profile
@Xliff
Xliff / Promisify.md
Created September 8, 2023 22:29
Running an asyncronous piece of code at a later date

I have a piece of asyncronous code I would like to run at a later date. I figured a Promise would suit this purpose fine.

So far this is what I have:

sub makePromise ( $o, $m, :$in = 0, :$args = @() ) {
  my $p = Promise.new;

 for $args {
@Xliff
Xliff / IMPL-CURRIED.md
Last active August 27, 2023 10:28
Where is the RakuAST Error, Here?
RakuAST::StatementList.new(
  RakuAST::Statement::Use.new(
    module-name => RakuAST::Name.from-identifier("Cro::HTTP::Router")
  ),
  RakuAST::Call::Name.new(
    name => RakuAST::Name.from-identifier("route"),
    args => RakuAST::ArgList.new(
      RakuAST::Block.new(
        body => RakuAST::Blockoid.new(
@Xliff
Xliff / FlameParser.md
Last active July 31, 2023 07:36
On Parsing ElectricSheep Flame Files....

Over the weekend, I wrote a module to do just that. It's early days still, as I'm sure there are tags that are not covered. I'll need to find the spec and have a nice long sit down before it's complete.

Here's what I have, though.

Have fun!

use XML::Class;
@Xliff
Xliff / BQNListOp.md
Last active June 13, 2023 11:07
To Raku - The BQN List Operator

The BQN list operator can readily transfer into Raku. It's basically the same as Raku's list operator: ,. There is a small devil in the detail and that can be illustrated in the following example:

multi sub infix:<> ($a, $b) { 
  infix:<,>($a, $b) 
}

say 1‿2‿3; # ((1 2) 3)
@Xliff
Xliff / BQN-Raku-Range.md
Last active June 15, 2023 03:14
BQN in Raku - Why not? Here's the range operator: ↕

I was just introduced to BQN, recently. While it won't be my first choice of language until I understand it a lot more, it does provide an interesting insight into all things Listy.

So I thought I might grab some low hanging fruit and bring some of that BQN goodness into Raku, a language that I -am- using on the daily.

Here's an implementation for the Range operator (↕):

multi sub prefix:<>(List() $l) { 
@Xliff
Xliff / BartAndLambda.md
Last active May 23, 2023 08:48
AI's are Writing in Raku, now!

I went to [bart.gooogle.com] and asked it: "How do you write lambda functions in Raku?"

Here's how it responded:

===

To write lambda functions in Raku, you can use the following syntax:

Code snippet

@Xliff
Xliff / Need RakuAST.md
Last active May 17, 2023 14:46
The need for ::Need
raku -Ilib -e 'use experimental :rakuast; use MONKEY-SEE-NO-EVAL; my $ast = RakuAST::Statement::Need.new( module-names => [ RakuAST::Name.from-identifier(RakuAST::Name.from-identifier("GLib::Raw::Definitions")) ] ); EVAL $ast; import ::("GLib::Raw::Definitions"); glib.say'

This is the exact testing data. It's execution ready if you clone p6-GLib, you should only need to change into the project directory and run the above. Otherwise you will have to create a .rakumod file with a constant declaration and replace the glib in the above script with the name of that constant.

@Xliff
Xliff / comp-unit-symbol-table.md
Last active March 19, 2023 12:02
Accessing a CompUnits Symbol Table

So I needed to access the symbol table of one of my modules, recently. After a few hours on the web (and after wracking my brain for a bit) I came up with the following:

sub getSymbolTable (\T, $cu-name) is export {
  return Nil unless $cu-name;

  my $nodes = $cu-name.split('::').Array;
  my $fn    = $nodes.shift;
 my $st = T.WHO{$fn};
@Xliff
Xliff / ParameterDEPARSE.md
Created February 7, 2023 17:59
Patch for RakuAST::Deparse for where clause and literal parameters

Does anyone see a problem with this? If so, I will submit the PR.

diff --git a/src/core.c/RakuAST/Deparse.pm6 b/src/core.c/RakuAST/Deparse.pm6
index ef073dbba..62410a414 100644
--- a/src/core.c/RakuAST/Deparse.pm6
+++ b/src/core.c/RakuAST/Deparse.pm6
@@ -619,6 +619,9 @@ class RakuAST::Deparse {
         my $target := $ast.target;
 
@Xliff
Xliff / rakuast-dir.md
Last active May 24, 2023 22:58
The RakuAST Node Directory (and Cheatsheet) as of Jan 22, 2023

Version 0.0.2 - Now includes attributes!

RakuAST::ApplyDottyInfix                                  - (ast/expressions.rakumod - 923)

	Attributes
		RakuAST::DottyInfixish $.infix
		RakuAST::Expression    $.left
		RakuAST::Postfixish    $.right