Skip to content

Instantly share code, notes, and snippets.

View Kaiepi's full-sized avatar
🤸
desing lonk

Ben Davies Kaiepi

🤸
desing lonk
View GitHub Profile
@Kaiepi
Kaiepi / fsitf.md
Last active September 17, 2022 17:57
Finding Structure in the Freeform: The Next Wave of Data::Record Changes

Finding Structure in the Freeform: The Next Wave of Data::Record Changes

Note: assumes knowledge gleanable from Data::Record's README and wiki.

I want to do a revision of record types in Data::Record as the user interacts with them from top to bottom, similarly to what v1.x's annotations-based API did for its internals. This would primarily involve the abandonment of the structural, structured, and unstructured keywords in favour of fixed and freeform, which would apply to all core record types. The notion of structured and unstructured data doesn't fit for this module in my view, which I tried to express poorly by naming unstructured data structural, because "structured" only applies to the strictest available wrap, and "unstructured" only applies to the loosest available coercion; the presence of semi-structured data is t

@Kaiepi
Kaiepi / annotations.md
Last active April 26, 2022 21:46
Annotating Types with Thread-Safe Containers

Annotating Types with Thread-Safe Containers

Back in December, I was hoping to write a new kind of type for Data::Record, but have been struggling with illness and a lengthy wait for a doctor's appointment. Despite my main computer dying off a few weeks ago, I've been able to toy with this idea to some degree.

The post linked is rather heady. If the kind of type is class-based, then a type can typecheck as another merely by inheriting from another (or its pun). What I'm looking for out of such a HOW is static state. If I can shove an array of fields for a record type into its HOW, then its operators can generate an annotation, inherit from such a class describing its behaviour, embed their fields in their HOW, and return them, with the unique MOP for lists, tuples, and hashes becoming possible to implement with metamethods alone.

Rakudo's MOP plays it rather

@Kaiepi
Kaiepi / Makefile
Last active September 7, 2021 22:35
bmake fizzbuzz
M:= m \
mm \
mmm \
mmmm \
mmmmm \
mmmmmm \
mmmmmmm \
mmmmmmmm \
mmmmmmmmm \
mmmmmmmmmm \
@Kaiepi
Kaiepi / monad.p6
Last active August 8, 2019 04:37
Monads in Perl 6
use v6.d;
role Monad[::T] {
method ACCEPTS(::?ROLE: ::?ROLE $m --> Bool:D) {
for $m.^attributes -> Attribute $x {
my Attribute $y = self.^get_attribute_for_usage: $x.name;
return False unless $x.get_value($m) ~~ $y.get_value(self);
}
True
}
@Kaiepi
Kaiepi / ps-logs-scraper.p6
Last active July 30, 2019 12:13
Pokémon Showdown Logs Scraper
# Instructions:
# - Save this as ps-logs-scraper.p6
# - Install Rakudo Star
# - Open up whatever terminal you use (cmd on Windows)
# - Enter "zef install Cro::HTTP JSON::Fast URI::Encode"
# - Change directory to wherever you saved this ("cd <directory>" on Windows)
# - Run perl6 ps-logs-scraper.p6 for usage instructions
#
# You will probably get a couple scary looking warnings beginning with
# "Trailing item in Hash.append" when running this script. Don't worry about this;
set shiftwidth=4
set tabstop=4
set softtabstop=4
set expandtab
set isk+=-
iabbrev <buffer> >> »
iabbrev <buffer> >>. ».
iabbrev <buffer> << «
set nocompatible
filetype off
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'VundleVim/vundle.vim'
Plugin 'Valloric/YouCompleteMe'
@Kaiepi
Kaiepi / csp.c
Last active May 7, 2021 02:53
CSP in C. Build with `gcc -o csp csp.c -lpthread`
#include <pthread.h>
#include <semaphore.h>
#include <stdlib.h>
#include <stdio.h>
struct channel_node {
void *val;
struct channel_node *next;
struct channel_node *prev;
};
@Kaiepi
Kaiepi / diff
Created June 11, 2018 02:16
Readline on OpenBSD
diff --git a/lib/Readline.pm b/lib/Readline.pm
index 347ae5b..ffc1f92 100644
--- a/lib/Readline.pm
+++ b/lib/Readline.pm
@@ -1,5 +1,13 @@
use v6;
use NativeCall;
+
+INIT {
+ if $*VM.osname eq 'openbsd' {