<commit_before># XXX Relatively cheaty, just to get us able to output something.
# But you should see what USED to be here! O.O
sub print(*@list) {
    nqp::print(@list.shift) while @list.gimme(1);
    1.Bool
}

sub say(|$) {
    my $args := pir::perl6_current_args_rpa__P();
    print nqp::shift($args).gist while $args;
    print "\n";
}

sub gist(|$) {
    pir__perl6_box_rpa__PP(pir::perl6_current_args_rpa__P()).gist
}

class IO {
    has $!PIO;
    has Int $.ins = 0;
    has $.chomp = 1.Bool;

    proto method open(|$) { * }
    multi method open($filename, :$r, :$w, :$a, :$bin, :$chomp = 1.Bool) {
        my $mode = $w ?? 'w' !! ($a ?? 'wa' !! 'r');
        # TODO: catch error, and fail()
        nqp::bindattr(self, IO, '$!PIO',
             $filename eq '-'
                ?? ( $w || $a ?? pir::getstdout__P() !! pir::getstdin__P() )
                !! pir::open__PSS(nqp::unbox_s($filename), nqp::unbox_s($mode))
        );
        $!chomp = $chomp;
        $!PIO.encoding($bin ?? 'binary' !! 'utf8');
        self;
    }

    method close() {
        # TODO:b catch errors
        $!PIO.close;
        1.Bool;
    }

    method eof() {
        nqp::p6bool($!PIO.eof);
    }

    method get() {
        my Str $x = nqp::p6box_s($!PIO.readline);
        # XXX don't fail() as long as it's fatal
        # fail('end of file') if self.eof && $x eq '';
        return Str if self.eof && $x eq '';

        $!ins++;
        # XXX
        # comment out as long as initiliaztion of attributes is a no-op
#        $!chomp ?? $x.chomp !! $x;
        $x.chomp;
    }

    method lines($limit = $Inf) {
        my $count = 0;
        gather while (my $line = self.get).defined && ++$count <= $limit {
            take $line;
        }
    }

    method print(*@list) {
        $!PIO.print(nqp::unbox_s(@list.shift.Str)) while @list.gimme(1);
        1.Bool
    }
    method say(|$) {
        my Mu $args := pir::perl6_current_args_rpa__P();
        nqp::shift($args);
        self.print: nqp::shift($args).gist while $args;
        self.print: "\n";
    }
}

proto sub open(|$) { * }
multi sub open($filename, :$r, :$w, :$a, :$bin, :$chomp = 1.Bool) {
    IO.new.open($filename, :$r, :$w, :$a, :$bin, :$chomp);
}

$PROCESS::IN  = open('-');
$PROCESS::OUT = open('-', :w);<commit_msg>set up $*ERR, jnthn++<commit_after># XXX Relatively cheaty, just to get us able to output something.
# But you should see what USED to be here! O.O
sub print(*@list) {
    nqp::print(@list.shift) while @list.gimme(1);
    1.Bool
}

sub say(|$) {
    my $args := pir::perl6_current_args_rpa__P();
    print nqp::shift($args).gist while $args;
    print "\n";
}

sub gist(|$) {
    pir__perl6_box_rpa__PP(pir::perl6_current_args_rpa__P()).gist
}

class IO {
    has $!PIO;
    has Int $.ins = 0;
    has $.chomp = 1.Bool;

    proto method open(|$) { * }
    multi method open($filename, :$r, :$w, :$a, :$bin, :$chomp = 1.Bool) {
        my $mode = $w ?? 'w' !! ($a ?? 'wa' !! 'r');
        # TODO: catch error, and fail()
        nqp::bindattr(self, IO, '$!PIO',
             $filename eq '-'
                ?? ( $w || $a ?? pir::getstdout__P() !! pir::getstdin__P() )
                !! pir::open__PSS(nqp::unbox_s($filename), nqp::unbox_s($mode))
        );
        $!chomp = $chomp;
        $!PIO.encoding($bin ?? 'binary' !! 'utf8');
        self;
    }

    method close() {
        # TODO:b catch errors
        $!PIO.close;
        1.Bool;
    }

    method eof() {
        nqp::p6bool($!PIO.eof);
    }

    method get() {
        my Str $x = nqp::p6box_s($!PIO.readline);
        # XXX don't fail() as long as it's fatal
        # fail('end of file') if self.eof && $x eq '';
        return Str if self.eof && $x eq '';

        $!ins++;
        # XXX
        # comment out as long as initiliaztion of attributes is a no-op
#        $!chomp ?? $x.chomp !! $x;
        $x.chomp;
    }

    method lines($limit = $Inf) {
        my $count = 0;
        gather while (my $line = self.get).defined && ++$count <= $limit {
            take $line;
        }
    }

    method print(*@list) {
        $!PIO.print(nqp::unbox_s(@list.shift.Str)) while @list.gimme(1);
        1.Bool
    }
    method say(|$) {
        my Mu $args := pir::perl6_current_args_rpa__P();
        nqp::shift($args);
        self.print: nqp::shift($args).gist while $args;
        self.print: "\n";
    }
}

proto sub open(|$) { * }
multi sub open($filename, :$r, :$w, :$a, :$bin, :$chomp = 1.Bool) {
    IO.new.open($filename, :$r, :$w, :$a, :$bin, :$chomp);
}

$PROCESS::IN  = open('-');
$PROCESS::OUT = open('-', :w);
$PROCESS::ERR = IO.new;
nqp::bindattr(pir::perl6_decontainerize__PP($PROCESS::ERR),
        IO, '$!PIO', pir::getstderr__P());
{'fraction_non_alphanumeric': 0.19953300785395883, 'fraction_numerical': 0.007429420505200594, 'mean_word_length': 2.2229822161422708, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3253503', 'n_tokens_mistral': 1822, 'n_tokens_neox': 1788, 'n_words': 418}