## typeobject.md
class X::Does::TypeObject

Error due to mixing into a type object

```raku
class X::Does::TypeObject is Exception {}
```

When you try to add one or more roles to a type object with `does` after it has been composed, an error of type `X::Does::TypeObject` is thrown:

```raku
Mu does Numeric;    # Cannot use 'does' operator with a type object.

```

The correct way to apply roles to a type is at declaration time:

```raku
class GrassmannNumber does Numeric { ... };
role AlgebraDebugger does IO { ... };
grammar IntegralParser does AlgebraParser { ... };

```

Roles may only be runtime-mixed into defined object instances:

```raku
GrassmannNumber.new does AlgebraDebugger;

```

(This restriction may be worked around by using [augment or supersede](/language/variables#The_augment_declarator), or with dark Metamodel magics, but this will likely result in a significant performance penalty.)

# [Methods](#class_X::Does::TypeObject "go to top of document")[§](#Methods "direct link")

## [method type](#class_X::Does::TypeObject "go to top of document")[§](#method_type "direct link")

```raku
method type(X::Does::TypeObject:D: --> Mu:U)
```

Returns the type object into which the code tried to mix in a role.


## dist_zef-gugod-RSV.md
```
This is an implementation of RSV decoder + encodder.

For the details of RSV, see:: https://github.com/Stenway/RSV-Specification

```


## numeric.md
Numeric

Combined from primary sources listed below.

# [In List](#___top "go to top of document")[§](#(List)_method_Numeric "direct link")

See primary documentation
[in context](/type/List#method_Numeric)
for **method Numeric**.

```raku
method Numeric(List:D: --> Int:D)
```

Returns the number of elements in the list (same as `.elems`).

```raku
say (1,2,3,4,5).Numeric; # OUTPUT: «5␤»
```

# [In role Sequence](#___top "go to top of document")[§](#(role_Sequence)_method_Numeric "direct link")

See primary documentation
[in context](/type/Sequence#method_Numeric)
for **method Numeric**.

```raku
method Numeric(::?CLASS:D:)
```

Returns the number of elements in the [cached](/type/PositionalBindFailover#method_cache) sequence.

# [In Capture](#___top "go to top of document")[§](#(Capture)_method_Numeric "direct link")

See primary documentation
[in context](/type/Capture#method_Numeric)
for **method Numeric**.

```raku
method Numeric(Capture:D: --> Int:D)
```

Returns the number of positional elements in the `Capture`.

```raku
say \(1,2,3, apples => 2).Numeric; # OUTPUT: «3␤»
```

# [In enum Bool](#___top "go to top of document")[§](#(enum_Bool)_routine_Numeric "direct link")

See primary documentation
[in context](/type/Bool#routine_Numeric)
for **routine Numeric**.

```raku
multi method Numeric(Bool:D --> Int:D)
```

Returns the value part of the `enum` pair.

```raku
say False.Numeric;                                # OUTPUT: «0␤»
say True.Numeric;                                 # OUTPUT: «1␤»
```

# [In X::AdHoc](#___top "go to top of document")[§](#(X::AdHoc)_method_Numeric "direct link")

See primary documentation
[in context](/type/X/AdHoc#method_Numeric)
for **method Numeric**.

```raku
method Numeric()
```

Converts the payload to [`Numeric`](/type/Numeric) and returns it

# [In IntStr](#___top "go to top of document")[§](#(IntStr)_method_Numeric "direct link")

See primary documentation
[in context](/type/IntStr#method_Numeric)
for **method Numeric**.

```raku
multi method Numeric(IntStr:D: --> Int:D)
multi method Numeric(IntStr:U: --> Int:D)
```

The `:D` variant returns the numeric portion of the invocant. The `:U` variant issues a warning about using an uninitialized value in numeric context and then returns value `0`.

# [In Str](#___top "go to top of document")[§](#(Str)_method_Numeric "direct link")

See primary documentation
[in context](/type/Str#method_Numeric)
for **method Numeric**.

```raku
method Numeric(Str:D: --> Numeric:D)
```

Coerces the string to [`Numeric`](/type/Numeric) using semantics equivalent to [val](/routine/val) routine. [Fails](/routine/fail) with [`X::Str::Numeric`](/type/X/Str/Numeric) if the coercion to a number cannot be done.

Only Unicode characters with property `Nd`, as well as leading and trailing whitespace are allowed, with the special case of the empty string being coerced to `0`. Synthetic codepoints (e.g. `"7\x[308]"`) are forbidden.

While `Nl` and `No` characters can be used as numeric literals in the language, their conversion via `Str.Numeric` will fail, by design; the same will happen with synthetic numerics (composed of numbers and diacritic marks). See [unival](/routine/unival) if you need to coerce such characters to [`Numeric`](/type/Numeric). +, - and the Unicode MINUS SIGN − are all allowed.

```raku
" −33".Numeric;       # OUTPUT: «-33␤»

```

# [In role Enumeration](#___top "go to top of document")[§](#(role_Enumeration)_method_Numeric "direct link")

See primary documentation
[in context](/type/Enumeration#method_Numeric)
for **method Numeric**.

```raku
multi method Numeric(::?CLASS:D:)
```

Takes a value of an enum and returns it after coercion to [`Numeric`](/type/Numeric):

```raku
enum Numbers ( cool => '42', almost-pi => '3.14', sqrt-n-one => 'i' );
say cool.Numeric;       # OUTPUT: «42␤»
say almost-pi.Numeric;  # OUTPUT: «3.14␤»
say sqrt-n-one.Numeric; # OUTPUT: «0+1i␤»
```

Note that if the value cannot be coerced to [`Numeric`](/type/Numeric), an exception will be thrown.

# [In NumStr](#___top "go to top of document")[§](#(NumStr)_method_Numeric "direct link")

See primary documentation
[in context](/type/NumStr#method_Numeric)
for **method Numeric**.

```raku
multi method Numeric(NumStr:D: --> Num:D)
multi method Numeric(NumStr:U: --> Num:D)
```

The `:D` variant returns the numeric portion of the invocant. The `:U` variant issues a warning about using an uninitialized value in numeric context and then returns value `0e0`.

# [In StrDistance](#___top "go to top of document")[§](#(StrDistance)_method_Numeric "direct link")

See primary documentation
[in context](/type/StrDistance#method_Numeric)
for **method Numeric**.

Returns the distance as a number.

# [In Map](#___top "go to top of document")[§](#(Map)_method_Numeric "direct link")

See primary documentation
[in context](/type/Map#method_Numeric)
for **method Numeric**.

```raku
method Numeric(Map:D: --> Int:D)
```

Returns the number of pairs stored in the `Map` (same as `.elems`).

```raku
my $m = Map.new('a' => 2, 'b' => 17);
say $m.Numeric;                                   # OUTPUT: «2␤»
```

# [In Nil](#___top "go to top of document")[§](#(Nil)_method_Numeric "direct link")

See primary documentation
[in context](/type/Nil#method_Numeric)
for **method Numeric**.

```raku
method Numeric()
```

Warns the user that they tried to numify a `Nil`.

# [In enum Endian](#___top "go to top of document")[§](#(enum_Endian)_routine_Numeric "direct link")

See primary documentation
[in context](/type/Endian#routine_Numeric)
for **routine Numeric**.

```raku
multi method Numeric(Endian:D --> Int:D)
```

Returns the value part of the `enum` pair.

```raku
say NativeEndian.Numeric;    # OUTPUT: «0␤»
say LittleEndian.Numeric;    # OUTPUT: «1␤»
say BigEndian.Numeric;       # OUTPUT: «2␤»
```

Note that the actual numeric values are subject to change. So please use the named values instead.

# [In IO::Path](#___top "go to top of document")[§](#(IO::Path)_method_Numeric "direct link")

See primary documentation
[in context](/type/IO/Path#method_Numeric)
for **method Numeric**.

```raku
method Numeric(IO::Path:D: --> Numeric:D)
```

Coerces [`.basename`](/routine/basename) to [`Numeric`](/type/Numeric). [Fails](/routine/fail) with [`X::Str::Numeric`](/type/X/Str/Numeric) if base name is not numerical.

# [In Thread](#___top "go to top of document")[§](#(Thread)_method_Numeric "direct link")

See primary documentation
[in context](/type/Thread#method_Numeric)
for **method Numeric**.

```raku
method Numeric(Thread:D: --> Int:D)
```

Returns a numeric, unique thread identifier, i.e. the same as [id](#method_id).

# [In role Numeric](#___top "go to top of document")[§](#(role_Numeric)_method_Numeric "direct link")

See primary documentation
[in context](/type/Numeric#method_Numeric)
for **method Numeric**.

```raku
multi method Numeric(Numeric:D: --> Numeric:D)
multi method Numeric(Numeric:U: --> Numeric:D)
```

The `:D` variant simply returns the invocant. The `:U` variant issues a warning about using an uninitialized value in numeric context and then returns `self.new`.

# [In DateTime](#___top "go to top of document")[§](#(DateTime)_method_Numeric "direct link")

See primary documentation
[in context](/type/DateTime#method_Numeric)
for **method Numeric**.

```raku
multi method Numeric(DateTime:D: --> Instant:D)
```

Available as of the 2021.09 release of the Rakudo compiler.

Converts the invocant to [`Instant`](/type/Instant). The same value can be obtained with the [`Instant`](/type/Instant) method. This allows `DateTime` objects to be used directly in arithmetic operations.

# [In ComplexStr](#___top "go to top of document")[§](#(ComplexStr)_method_Numeric "direct link")

See primary documentation
[in context](/type/ComplexStr#method_Numeric)
for **method Numeric**.

```raku
multi method Numeric(ComplexStr:D: --> Complex:D)
multi method Numeric(ComplexStr:U: --> Complex:D)
```

The `:D` variant returns the numeric portion of the invocant. The `:U` variant issues a warning about using an uninitialized value in numeric context and then returns value `<0+0i>`.

# [In RatStr](#___top "go to top of document")[§](#(RatStr)_method_Numeric "direct link")

See primary documentation
[in context](/type/RatStr#method_Numeric)
for **method Numeric**.

```raku
multi method Numeric(RatStr:D: --> Rat:D)
multi method Numeric(RatStr:U: --> Rat:D)
```

The `:D` variant returns the numeric portion of the invocant. The `:U` variant issues a warning about using an uninitialized value in numeric context and then returns value `0.0`.

# [In Date](#___top "go to top of document")[§](#(Date)_method_Numeric "direct link")

See primary documentation
[in context](/type/Date#method_Numeric)
for **method Numeric**.

```raku
multi method Numeric(Date:D: --> Int:D)
```

Converts the invocant to [`Int`](/type/Int). The same value can be obtained with the `daycount` method. This allows `Date` objects to be used directly in arithmetic operations.

Available as of release 2023.02 of the Rakudo compiler.


## dist_zef-frithnanth-Math-Libgsl-Interpolation.md
[![Actions Status](https://github.com/frithnanth/raku-Math-Libgsl-Interpolation/workflows/test/badge.svg)](https://github.com/frithnanth/raku-Math-Libgsl-Interpolation/actions)

![2D spline interpolation](examples/04-raw.png)

# NAME

Math::Libgsl::Interpolation - An interface to libgsl, the Gnu Scientific Library - Interpolation

# SYNOPSIS

```
use Math::Libgsl::Constants;
use Math::Libgsl::Interpolation;

my constant \N = 4;
my Num @x = 0e0, .1e0, .27e0, .3e0;
my Num @y = .15e0, .7e0, -.1e0, .15e0;

my $s = Math::Libgsl::Interpolation::OneD.new(:type(CSPLINE_PERIODIC), :size(N), :spline).init(@x, @y);

for ^100 -> $i {
  my Num $xi = (1 - $i / 100) * @x[0] + ($i / 100) * @x[N - 1];
  my Num $yi = $s.eval: $xi;
  printf "%g %g\n", $xi, $yi;
}

```

# DESCRIPTION

Math::Libgsl::Interpolation is an interface to the interpolation functions of libgsl, the Gnu Scientific Library. This module exports two classes:

* Math::Libgsl::Interpolation::OneD
* Math::Libgsl::Interpolation::TwoD

## Math::Libgsl::Interpolation::OneD

### new(Int $type!, Int $size!)

### new(Int :$type!, Int :$size!)

This **multi method** constructor requires two simple or named arguments, the type of interpolation and the size of the array of data points.

### init(Num() @xarray where ([<] @xarray), Num() @yarray --> Math::Libgsl::Interpolation::OneD)

This method initializes the interpolation internal data using the X and Y coordinate arrays. It must be called each time one wants to use the object to evaluate interpolation points on another data set. The X array has to be strictly ordered, with increasing x values. This method returns **self**, so it may be chained.

### min-size(--> UInt)

This method returns the minimum number of points required by the interpolation object.

### name(--> Str)

This method returns the name of the interpolation type.

### find(Num() @xarray, Num() $x --> UInt)

This method performs a lookup action on the data array **@xarray** and returns the index i such that @xarray[i] <= $x < @xarray[i+1].

### reset(--> Math::Libgsl::Interpolation::OneD)

This method reinitializes the internal data structure and deletes the cache. It should be used when switching to a new dataset. This method returns **self**, so it may be chained.

### eval(Num() $x where $!spline.interp.xmin ≤ \* ≤ $!spline.interp.xmax --> Num)

This method returns the interpolated value of y for a given point x, which is inside the range of the x data set.

### eval-deriv(Num() $x where $!spline.interp.xmin ≤ \* ≤ $!spline.interp.xmax --> Num)

This method returns the derivative of an interpolated function for a given point x, which is inside the range of the x data set.

### eval-deriv2(Num() $x where $!spline.interp.xmin ≤ \* ≤ $!spline.interp.xmax --> Num)

This method returns the second derivative of an interpolated function for a given point x, which is inside the range of the x data set.

### eval-integ(Num() $a where $!spline.interp.xmin ≤ \*, Num() $b where { $b ≤ $!spline.interp.xmax && $b ≥ $a } --> Num)

This method returns the numerical integral result of an interpolated function over the range [$a, $b], two points inside the x data set.

## Math::Libgsl::Interpolation::TwoD

### new(Int $type!, Int $xsize!, Int $ysize!)

### new(Int :$type!, Int :$xsize!, Int :$ysize!)

This **multi method** constructor requires three simple or named arguments, the type of interpolation and the size of the arrays of the x and y data points.

### init(Num() @xarray where ([<] @xarray), Num() @yarray where ([<] @yarray), Num() @zarray where \*.elems == @xarray.elems \* @yarray.elems --> Math::Libgsl::Interpolation::TwoD)

This method initializes the interpolation internal data using the X, Y, and Z coordinate arrays. It must be called each time one wants to use the object to evaluate interpolation points on another data set. The X and Y arrays have to be strictly ordered, with increasing values. The Z array, which represents a grid, must have a dimension of size xsize \* ysize. The position of grid point (x, y) is given by y \* xsize + x (see also the zidx method). This method returns **self**, so it may be chained.

### zidx(UInt $x, UInt $y --> UInt)

This method returns the index of the Z array element corresponding to grid coordinates (x, y).

### min-size(--> UInt)

This method returns the minimum number of points required by the interpolation object.

### name(--> Str)

This method returns the name of the interpolation type.

### eval(Num() $x where $!spline.interp.xmin ≤ \* ≤ $!spline.interp.xmax, Num() $y where $!spline.interp.ymin ≤ \* ≤ $!spline.interp.ymax --> Num)

This method returns the interpolated value of z for a given point (x, y), which is inside the range of the x and y data sets.

### extrap(Num() $x, Num() $y --> Num)

This method returns the interpolated value of z for a given point (x, y), with no bounds checking, so when the point (x, y) is outside the range, an extrapolation is performed.

### deriv-x(Num() $x where $!spline.interp.xmin ≤ \* ≤ $!spline.interp.xmax, Num() $y where $!spline.interp.ymin ≤ \* ≤ $!spline.interp.ymax --> Num)

This method returns the interpolated value of ∂z/∂x for a given point (x, y), which is inside the range of the x and y data sets.

### deriv-y(Num() $x where $!spline.interp.xmin ≤ \* ≤ $!spline.interp.xmax, Num() $y where $!spline.interp.ymin ≤ \* ≤ $!spline.interp.ymax --> Num)

This method returns the interpolated value of ∂z/∂y for a given point (x, y), which is inside the range of the x and y data sets.

### deriv-xx(Num() $x where $!spline.interp.xmin ≤ \* ≤ $!spline.interp.xmax, Num() $y where $!spline.interp.ymin ≤ \* ≤ $!spline.interp.ymax --> Num)

This method returns the interpolated value of ∂²z/∂²x for a given point (x, y), which is inside the range of the x and y data sets.

### deriv-yy(Num() $x where $!spline.interp.xmin ≤ \* ≤ $!spline.interp.xmax, Num() $y where $!spline.interp.ymin ≤ \* ≤ $!spline.interp.ymax --> Num)

This method returns the interpolated value of ∂²z/∂²y for a given point (x, y), which is inside the range of the x and y data sets.

### deriv-xy(Num() $x where $!spline.interp.xmin ≤ \* ≤ $!spline.interp.xmax, Num() $y where $!spline.interp.ymin ≤ \* ≤ $!spline.interp.ymax --> Num)

This method returns the interpolated value of ∂²z/∂x∂y for a given point (x, y), which is inside the range of the x and y data sets.

## Accessory subroutines

### bsearch(Num() @xarray, Num() $x, UInt $idx-lo = 0, UInt $idx-hi = @xarray.elems - 1 --> UInt)

This sub returns the index i of the array @xarray such that @xarray[i] <= $x < @xarray[i+1]. The index is searched for in the range [$idx-lo, $idx-hi].

### min-size(Int $type --> UInt)

### min-size1d(Int $type --> UInt)

### min-size2d(Int $type --> UInt)

These subs return the minimum number of points required by the interpolation object, without the need to create an object. min-size is an alias for min-size1d.

# C Library Documentation

For more details on libgsl see <https://www.gnu.org/software/gsl/>. The excellent C Library manual is available here <https://www.gnu.org/software/gsl/doc/html/index.html>, or here <https://www.gnu.org/software/gsl/doc/latex/gsl-ref.pdf> in PDF format.

# Prerequisites

This module requires the libgsl library to be installed. Please follow the instructions below based on your platform:

## Debian Linux and Ubuntu 20.04

```
sudo apt install libgsl23 libgsl-dev libgslcblas0

```

That command will install libgslcblas0 as well, since it's used by the GSL.

## Ubuntu 18.04

libgsl23 and libgslcblas0 have a missing symbol on Ubuntu 18.04. I solved the issue installing the Debian Buster version of those three libraries:

* <http://http.us.debian.org/debian/pool/main/g/gsl/libgslcblas0_2.5+dfsg-6_amd64.deb>
* <http://http.us.debian.org/debian/pool/main/g/gsl/libgsl23_2.5+dfsg-6_amd64.deb>
* <http://http.us.debian.org/debian/pool/main/g/gsl/libgsl-dev_2.5+dfsg-6_amd64.deb>

# Installation

To install it using zef (a module management tool):

```
$ zef install Math::Libgsl::Interpolation

```

# AUTHOR

Fernando Santagata [nando.santagata@gmail.com](mailto:nando.santagata@gmail.com)

# COPYRIGHT AND LICENSE

Copyright 2021 Fernando Santagata

This library is free software; you can redistribute it and/or modify it under the Artistic License 2.0.


## dist_cpan-MORITZ-JSON-Tiny.md
# Example

A simple Perl 6 module for serializing and deserializing JSON.

```
use JSON::Tiny;
say from-json('{ "a": 42 }').perl;
say to-json { a => [1, 2, 'b'] };

```

# Supported Standards

JSON::Tiny implements RFC7159, which is a superset of ECMA-404, in that it
permits any value as a top-level JSON string, not just arrays and objects.

# License

All files (unless noted otherwise) can be used, modified and redistributed
under the terms of the Artistic License Version 2. Examples (in the
documentation, in tests or distributed as separate files) can be considered
public domain.

# Installation and Tests

To install this module, please use zef from <https://github.com/ugexe/zef> and
type

```
zef install JSON::Tiny

```

or from a checkout of this source tree,

```
zef install .

```

You can run the test suite locally like this:

```
prove -e 'perl6 -Ilib' t/

```


## dist_zef-FCO-Functional-Stack.md
[![Actions Status](https://github.com/FCO/Functional-Stack/actions/workflows/test.yml/badge.svg)](https://github.com/FCO/Functional-Stack/actions)

# NAME

Functional::Stack - Functional Stack

# SYNOPSIS

```
use Functional::Stack;
Functional::Stack.mutate: {
   for ^10 -> $value { say .push: $value }
   say .peek;
   say .pop while .elems;
}

```

# DESCRIPTION

Functional::Stack is a implementation of a functional data structure stack. It's immutable and thread-safe.

It has a `mutate` method that topicalise the object and will always topicalise the new generated stack. And that's gives the impression of mutating and makes it easier to interact with those objects.

# AUTHOR

Fernando Corrêa de Oliveira [fco@cpan.org](mailto:fco@cpan.org)

# COPYRIGHT AND LICENSE

Copyright 2024 Fernando Corrêa de Oliveira

This library is free software; you can redistribute it and/or modify it under the Artistic License 2.0.


## dist_zef-jjmerelo-Dist-META.md
# Dist::META [Test-install distro](https://github.com/JJ/raku-dist-meta/actions/workflows/test.yaml)

The main intention of this module is to offer an uniform API for data that
might be spread over different keys in the
[`META6.json` file](https://docs.raku.org/language/modules#index-entry-META6.json-META6.json).

This initial version, however, will focus on getting dependencies right, in a
single array.

## Installing

The usual

```
zef install Dist::META

```

## Running

`Dist::META` subclasses [`META6`](https://github.com/jonathanstowe/META6); please check out that distribution for its common API. It adds a class
attribute, `.dependencies`. Over this META6.json

```
{
  "name" : "JSON::Marshal",
  "tags" : [ "object", "serialisation", "JSON" ],
  "authors" : [ "Jonathan Stowe <jns+git@gellyfish.co.uk>" ],
  "author" : "Jonathan Stowe <jns+git@gellyfish.co.uk>",
  "auth" : "github:jonathanstowe",
  "support" : {
    "source" : "git://github.com/jonathanstowe/JSON-Marshal.git"
  },
  "source-url" : "git://github.com/jonathanstowe/JSON-Marshal.git",
  "perl" : "6",
  "build-depends" : [ ],
  "provides" : {
     "JSON::Marshal" : "lib/JSON/Marshal.pm"
  },
  "depends" : [ "JSON::Tiny" ],
  "test-depends" : [
    "Test"
  ],
  "description" : "Simple serialisation of objects to JSON",
  "version" : "0.0.1"
}

```

You can run this program

```
use Dist::META;
my $obj = Dist::META.new(file => $meta-path); # Use path to above file
say $obj.dependencies[0]; # Prints JSON::Tiny
say $obj.dependencies[0].DependencyType; # RUNTIMEDEP
say $obj.dependencies[1].DependencyType; # TESTDEP;

```

`.dependencies` is an array with all dependencies, "tagged" (using mix-ins
) with `RUNTIMEDEP`,`BUILDDEP` or `TESTDEP`, depending on where they have
been defined (independently of the META6.json key they have used).

## See also

[Test::META](https://github.com/jonathanstowe/Test-META/) tests that
specifications are correct. [`Pakku::Spec`](https://github.com/hythm7/Pakku-Spec), part of the Pakku package manager, also contains a parser for
`META6.json that is closer to the current spec.

## License

This module will be licensed under the Artistic 2.0 License.


## dist_zef-Altai-man-Config-Netrc.md
# NAME

Config::Netrc - module for parsing of Netrc configuration files.

# SYNOPSIS

```
use Config::Netrc;
say Config::Netrc::parse-file('my-example.netrc');

```

# DESCRIPTION

There are basically two main functions: parse and parse-file. First function takes a string of netrc-file content and returns to you a hash with some signature or Nil value if parser failed.

This hash contains of two arrays: `comments` and `entries`. In the section comments you will get all comment strings(without leading `#`) and in the entries section you get array of hashes with this structure:

```
machine  => {value => val, comment => my-comment},
login    => {value => val, comment => my-comment},
password => {value => val, comment => my-comment}

```

Of course, login or password lines are optional and comment entry for lines like following:

```
machine val # my-comment

```

is also optional.

You will be able to use this hash to determine state of user's Netrc file state.

# TODO

* Detection of user's config file at his `home` directory

# COPYRIGHT

This library is free software; you can redistribute it and/or modify it under the terms of the [Artistic License 2.0](http://www.perlfoundation.org/artistic_license_2_0)


## dist_zef-thundergnat-App-pixelpick.md
# NAME pixelpick

Get the color of any screen pixel in an X11 environment.

Simple command-line app to allow you to get the RGB color of ***any*** screen pixel in an X11 environment, even those controlled by another application.

### Install

```
zef install App::pixelpick

```

Needs to have the `import` utility available. Installed part of the `MagickWand` package. Most Linuxes have it already, if not, install `libmagickwand`. May want to install `libmagickwand-dev` as well, though it isn't strictly necessary for this app.

```
sudo apt-get install libmagickwand-dev

```

For Debian based distributions.

Uses the `X11::libxdo` module for mouse interaction so will only run in an X11 environment.

## Use

### Interactive:

```
pixelpick <--distance=Int> <--list=COLOR,LISTS>

```

If invoked with no positional parameters, runs in interactive mode. Will get the color of the pixel under the mouse pointer and show the RGB values in both decimal and hexadecimal formats and will display a small block colored to that value. Will also display colored blocks of "Named colors", along with their RGB values, that are "near" the selected color.

Will accept an Integer "distance" parameter at the command line to fine tune the cutoff for what is "near". (Defaults to 20. More than about 80 or so is not recommended. You'll get unusefully large numbers of matches.) Will always return at least one "nearest" color, no matter what the threshold is. The colors may not be exact, they are just the nearest found in the list.

Uses the XKCD CSS3 and X11 color name lists from the Color::Names module by default as its list of known colors.

See [XKCD color blocks](https://www.w3schools.com/colors/colors_xkcd.asp), [W3 CSS 3 standard web colors](https://www.w3schools.com/cssref/css_colors.asp), and [X11 color blocks](https://www.w3schools.com/colors/colors_x11.asp).

If different color lists are desired, pass in a comma joined list of names. Any of the lists supported by `Color::Names:api<2>` may be used.

```
X11 XKCD CSS3 X11-Grey NCS NBS Crayola Resene RAL-CL RAL-DSP FS595B FS595C

```

as of this writing. The (case-sensitive) names must be in one contiuous string joined by commas. E.G.

```
pixelpick --list=Crayola,XKCD

```

Updates moderately slowly as the mouse is moved. There is some delay just to slow down the busy loop of checking to see if the mouse has moved. Will not attempt to update if the mouse has not moved. Uses the `X11::xdo` module to capture mouse motion so will only work in an X11 environment.

Note that screen sub-pixel dithering may lead to some unexpected values being returned, especially around small text. The utility returns what the pixel color ***is***, not what it is perceived to be.

When in interactive mode, you need to send an abort signal to exit the utility. Control-C will reset your terminal to its previous settings and do a full clean-up. If you want to keep the color block and values around, do Control-Z instead. That will also reset the terminal, but will not clean up as much, effectively leaving the last values displayed.

### Non-interactive: (Get the color of the pixel at 100, 200)

```
pixelpick 100 200 (--distance=Int)

```

If invoked with X, Y coordinates, (--distance parameter optional) runs non-interactive. Gets the pixel color at that coordinate and exits immediately, doing the partial cleanup as you would get from Control-Z.

### Non-interactive, quiet: (Get the RGB values of the pixel at 100, 200)

```
pixelpick 100 200 q

```

Add a truthy value as a "quiet" parameter to not return the standard color parameters and block. Only returns the RGB values in base 10 separated by colons. EG. `RRR:GGG:BBB`

If you would prefer to receive hex values, use an 'h' as the quiet parameter. Returns the RGB values in hexadecimal, separated by colons; `RR:GG:BB`.

```
pixelpick 100 200 h

```

# Author

2019 thundergnat (Steve Schulze)

This package is free software and is provided "as is" without express or implied warranty. You can redistribute it and/or modify it under the same terms as Perl itself.

# License

Licensed under The Artistic 2.0; see LICENSE.


## c3mro.md
role Metamodel::C3MRO

Metaobject that supports the C3 method resolution order

```raku
role Metamodel::C3MRO { }
```

*Warning*: this role is part of the Rakudo implementation, and is not a part of the language specification.

[Metamodel](/language/mop) role for the [*C3* method resolution order (MRO)](https://en.wikipedia.org/wiki/C3_linearization). *Note*: this method, along with almost the whole metamodel, is part of the Rakudo implementation.

The *method resolution order* for a type is a flat list of types including the type itself, and (recursively) all super classes. It determines in which order the types will be visited for determining which method to call with a given name, or for finding the next method in a chain with [nextsame](/language/functions#sub_nextsame), [callsame](/language/functions#sub_callsame), [nextwith](/language/functions#sub_nextwith) or [callwith](/language/functions#sub_callwith).

```raku
class CommonAncestor { };   # implicitly inherits from Any
class Child1 is CommonAncestor { }
class Child2 is CommonAncestor { }
class GrandChild2 is Child2 { }
class Weird is Child1 is GrandChild2 { };

say Weird.^mro; # OUTPUT: «(Weird) (Child1) (GrandChild2) (Child2) (CommonAncestor) (Any) (Mu)␤»

```

C3 is the default resolution order for classes and grammars in Raku. Note that roles generally do not appear in the method resolution order (unless they are punned into a class, from which another type inherits), because methods are copied into classes at role application time.

# [Methods](#role_Metamodel::C3MRO "go to top of document")[§](#Methods "direct link")

## [method compute\_mro](#role_Metamodel::C3MRO "go to top of document")[§](#method_compute_mro "direct link")

```raku
method compute_mro($type)
```

Computes the method resolution order.

## [method mro](#role_Metamodel::C3MRO "go to top of document")[§](#method_mro "direct link")

```raku
method mro($type)
```

Returns a list of types in the method resolution order, even those that are marked `is hidden`.

```raku
say Int.^mro;   # OUTPUT: «((Int) (Cool) (Any) (Mu))␤»
```

## [method mro\_unhidden](#role_Metamodel::C3MRO "go to top of document")[§](#method_mro_unhidden "direct link")

```raku
method mro_unhidden($type)
```

Returns a list of types in method resolution order, excluding those that are marked with `is hidden`.


## sub.md
sub

Combined from primary sources listed below.

# [In Functions](#___top "go to top of document")[§](#(Functions)_sub_sub "direct link")

See primary documentation
[in context](/language/functions#Subroutines)
for **Subroutines**.

The basic way to create a subroutine is to use the `sub` declarator followed by an optional [identifier](/language/syntax#Identifiers):

```raku
sub my-func { say "Look ma, no args!" }
my-func;
```

The sub declarator returns a value of type [`Sub`](/type/Sub) that can be stored in any container:

```raku
my &c = sub { say "Look ma, no name!" }
c;     # OUTPUT: «Look ma, no name!␤»

my Any:D $f = sub { say 'Still nameless...' }
$f();  # OUTPUT: «Still nameless...␤»

my Code \a = sub { say ‚raw containers don't implement postcircumfix:<( )>‘ };
a.();  # OUTPUT: «raw containers don't implement postcircumfix:<( )>␤»
```

The declarator `sub` will declare a new name in the current scope at compile time. As such, any indirection has to be resolved at compile time:

```raku
constant aname = 'foo';
sub ::(aname) { say 'oi‽' };
foo;
```

This will become more useful once macros are added to Raku.

To have the subroutine take arguments, a [`Signature`](/type/Signature) goes between the subroutine's name and its body, in parentheses:

```raku
sub exclaim ($phrase) {
    say $phrase ~ "!!!!"
}
exclaim "Howdy, World";

```

By default, subroutines are [lexically scoped](/syntax/my). That is, `sub foo {...}` is the same as `my sub foo {...}` and is only defined within the current scope.

```raku
sub escape($str) {
    # Puts a slash before non-alphanumeric characters
    S:g[<-alpha -digit>] = "\\$/" given $str
}

say escape 'foo#bar?'; # OUTPUT: «foo\#bar\?␤»

{
    sub escape($str) {
        # Writes each non-alphanumeric character in its hexadecimal escape
        S:g[<-alpha -digit>] = "\\x[{ $/.ord.base(16) }]" given $str
    }

    say escape 'foo#bar?' # OUTPUT: «foo\x[23]bar\x[3F]␤»
}

# Back to original escape function
say escape 'foo#bar?'; # OUTPUT: «foo\#bar\?␤»

```

Subroutines don't have to be named. If unnamed, they're called *anonymous* subroutines.

```raku
say sub ($a, $b) { $a ** 2 + $b ** 2 }(3, 4) # OUTPUT: «25␤»
```

But in this case, it's often desirable to use the more succinct [`Block`](/type/Block) syntax. Subroutines and blocks can be called in place, as in the example above.

```raku
say -> $a, $b { $a ** 2 + $b ** 2 }(3, 4)    # OUTPUT: «25␤»
```

Or even

```raku
say { $^a ** 2 + $^b ** 2 }(3, 4)            # OUTPUT: «25␤»
```


## is-dynamic.md
is dynamic

Combined from primary sources listed below.

# [In Variable](#___top "go to top of document")[§](#(Variable)_trait_is_dynamic "direct link")

See primary documentation
[in context](/type/Variable#trait_is_dynamic)
for **trait is dynamic**.

```raku
multi trait_mod:<is>(Variable:D, :$dynamic)
```

Marks a variable as dynamic, that is, accessible from inner dynamic scopes without being in an inner lexical scope.

```raku
sub introspect() {
    say $CALLER::x;
}
my $x is dynamic = 23;
introspect;         # OUTPUT: «23␤»
{
    # not dynamic
    my $x;
    introspect()    # dies with an exception of X::Caller::NotDynamic
}

```

The `is dynamic` trait is a rather cumbersome way of creating and accessing dynamic variables. A much easier way is to use the `* twigil`:

```raku
sub introspect() {
    say $*x;
}
my $*x = 23;
introspect;         # OUTPUT: «23␤»
{
    # not dynamic
    my $x;
    introspect()    # dies with an exception of X::Dynamic::NotFound
}

```


## dist_zef-lizmat-Needle-Compile.md
[![Actions Status](https://github.com/lizmat/Needle-Compile/actions/workflows/linux.yml/badge.svg)](https://github.com/lizmat/Needle-Compile/actions) [![Actions Status](https://github.com/lizmat/Needle-Compile/actions/workflows/macos.yml/badge.svg)](https://github.com/lizmat/Needle-Compile/actions) [![Actions Status](https://github.com/lizmat/Needle-Compile/actions/workflows/windows.yml/badge.svg)](https://github.com/lizmat/Needle-Compile/actions)

# NAME

Needle::Compile - compile a search needle specification

# SYNOPSIS

```
use Needle::Compile;

my &basic = compile-needle("bar");
say basic("foo bar baz");             # True
say basic("Huey, Dewey, and Louie");  # False

my &capitals-ok = compile-needle("bar", :ignorecase);
say capitals-ok("foo bar baz");             # True
say capitals-ok("FOO BAR BAZ");             # True
say capitals-ok("Huey, Dewey, and Louie");  # False

my &regex-ok = compile-needle("regex" => '\w+');
say regex-ok("foo");  # True
say regex-ok(":;+");  # False

my &regex-matches = compile-needle("regex" => '\w+', :matches);
say regex-matches(":foo:");  # (foo)
say regex-matches(":;+");    # False

```

# DESCRIPTION

Needle::Compile exports a subroutine "compile-needle" that takes a number of arguments that specify a search query needle, and returns a `Callable` that can be called with a given haystack to see if there is a match.

It can as such be used as the argument to the `rak` subroutine provided by the [`rak`](https://raku.land/zef:lizmat/rak) distribution.

# SEARCH QUERY SPECIFICATION

A query can consist of multiple needles of different types. A type of needle can be specified in 3 ways:

### implicitely

```
# accept haystack if "bar" as word is found
my &needle = compile-needle("§bar");

```

By using textual markers at the start and end of the given string needle (see: type is "auto").

### explicitely

```
# accept haystack if "bar" as word is found
my &needle = compile-needle("words" => "bar");

```

By specifying a needle as a `Pair`, with the key being a string describing the type.

### mixed in

```
use Needle::Compile "Type";

# accept haystack if "bar" as word is found
my &needle = compile-needle("bar" but Type("words"));

```

If the specified needle supports a `.type` method, then that method will be called to determine the type. This can be done with the `Type` role that is optionally exported.

If you specify `"Type"` in the `use` statement, a `Type` role will be exported that allows you to mixin a type with a given string. The `Type` role will only allow known types in its specification. If that is too restrictive for your application, you can define your own `Type` role. Which can be as simple as:

```
my role Type { $.type }

```

If you want to be able to dispatch on strings that have a `but Type` mixed in, you can also import the `StrType` class:

```
use Needle::Compile <Type StrType>;

say "foo" but Type<words> ~~ Str;      # True
say "foo" but Type<words> ~~ StrType;  # True
say "foo"                 ~~ StrType;  # False

```

Furthermore, you can call the `.ACCEPTS` method on the `StrTtype` class to check whether a given type string is valid:

```
use Needle::Compile <Type StrType>;

say StrType.ACCEPTS("contains");    # True
say StrType.ACCEPTS("frobnicate");  # False

```

## Modifiers

Many types of matching support `ignorecase` and `ignoremark` semantics. These can be specified explicitely (with the `:ignorecase` and `:ignoremark` named arguments), or implicitely with the `:smartcase` and `:smartmark` named arguments.

The same types also support the <:match> named argument, to return the string that actually matched, rather than `True`.

### ignorecase

```
# accept haystack if "bar" is found, regardless of case
my &needle = compile-needle("bar", :ignorecase);

```

Allow characters to match even if they are of mixed case.

### smartcase

```
# accept haystack if "bar" is found, regardless of case
my &anycase = compile-needle("bar", :smartcase);

# accept haystack if "Bar" is found
my &exactcase = compile-needle("Bar", :smartcase);

```

If the needle is a string and does **not** contain any uppercase characters, then `ignorecase` semantics will be assumed.

### ignoremark

```
# accept haystack if "bar" is found, regardless of any accents
my &anycase = compile-needle("bar", :ignoremark);

```

Allow characters to match even if they have accents (or not).

### smartmark

```
# accept haystack if "bar" is found, regardless of any accents
my &anymark = compile-needle("bar", :smartmark);

# accept haystack if "bår" is found
my &exactmark = compile-needle("bår", :smartmark);

```

If the needle is a string and does **not** contain any characters with accents, then `ignoremark` semantics will be assumed.

### matches

```
my &regex-matches = compile-needle("regex" => '\w+', :matches);
say regex-matches(":foo:");  # (foo)
say regex-matches(":;+");    # False

```

Return all the strings that matched as a `Slip`, rather than `True`. Will still return `False` if no matches were found.

## Types of matchers

### auto

This is the default type of matcher. It looks at the given string for a number of markers, and adjust the type of match and the string accordingly. The following markers are recognized:

#### starts with !

```
# accept haystack if "bar" is NOT found
my &needle = compile-needle('!bar');

```

This is a meta-marker. Assumes the string given (without the `!`) should be processed, and its result negated (see: type is "not").

#### starts with &

```
# accept haystack if "foo" and "bar" are found
my &needle = compile-needle('foo', '&bar');

```

This is a meta-marker. Marks the needle produced for the given string (without the `&`) as needing an `&&` infix with its predecessor be processed, rather than the default `||` infix (see: type is "and").

#### starts with §

```
# accept haystack if "bar" is found as a word
my &needle = compile-needle('§bar');

```

Assumes the string given (without the `§`) should match with word-boundary semantics applied (see: type is "words").

#### starts with \*

```
# accept haystack if alphabetically before "bar"
my &is-before = compile-needle('* before "bar"');

# return every haystack uppercased
my &uppercased = compile-needle('*.uc');

```

Assumes the given string is a valid `WhateverCode` specification and attempts to produce that specification accordingly (see: type is "code").

#### starts with ^

```
# accept haystack if it starts with "bar"
my &needle = compile-needle('^bar');

```

Assumes the string given (without the `^`) should match with `.starts-with` semantics applied (see: type is "starts-with").

#### starts with file:

```
# accept matching patterns in file "always"
my &needle = compile-needle('file:always');

```

Assumes the given string (without the `file:` prefix) is a valid path specification, pointing to a file containing the patterns to be used (see: type is "file").

#### starts with jp:

```
# return result of JSON::Path query "auth"
my &needle = compile-needle('jp:auth');

```

Assumes the given string (without the `jp:` prefix) is a valid [`JSON Path`](https://en.wikipedia.org/wiki/JSONPath) specification (see: type is "json-path").

#### starts with s:

```
# accept if string contains "foo" *and* "bar"
my &needle = compile-needle('s:foo &bar');

```

Splits the given string (without the `s:` prefix) on whitespace and interpretes the result as a list of needles (see: type is "split").

#### starts with url:

```
# accept if any of the needles at given URL matches
my &domain = compile-needle('url:raku.org/robots.txt');  # assumes https://
my &url    = compile-needle('url:https://raku.org/robots.txt');

```

Interpretes the given string (without the `url:` prefix) as a URL from which to obtain the needles from (see: type is "url").

#### ends with $

```
# accept haystack if it ends with "bar"
my &needle = compile-needle('bar$');

```

Assumes the string given (without the `$`) should match with `.ends-with` semantics applied (see: type is "ends-with").

#### starts with ^ and ends with $

```
# accept haystack if it is equal to "bar"
my &needle = compile-needle('^bar$');

```

Assumes the string given (without the `^` and `$`) should match exactly (see: type is "equal").

#### starts with / and ends with /

```
# accept haystack if it matches "bar" as a regular expression
my &needle = compile-needle('/bar/');

```

Assumes the string given (without the `/`'s) is a regex and attempts to produce a `Regex` object and wraps that in a call to `.contains` (see: type is "regex").

#### starts with { and ends with }

```
# return the lowercased, whitespace trimmed haystack
my &needle = compile-needle('{.trim.lc}');

```

Assumes the string given (without the `{` and `}`) is an expression and attempts to produce the code (see: type is "code").

#### none of the above

```
# accept haystack if it contains "bar"
my &needle = compile-needle("bar");

```

Assumes the string given should match with `.contains` semantics applied (see: type is "contains").

### and

```
# accept haystack if "foo" and "bar" are found
my &needle = compile-needle('foo', "and" => 'bar');

```

This is a meta-marker. Marks the needle produced for the given string as needing an `&&` infix with its predecessor be processed, rather than the default `||` infix. Has no meaning on the first (or only) needle in a list of needles.

### code

```
# return uppercase version of the haystack
my &needle = compile-needle("code" => ".uc");

```

Assumes the string is an expression and attempts to produce that code, with the haystack being presented as the topic (`$_`).

To facilitate the use of libraries that wish to access that topic, it is also available as the `$*_` dynamic variable.

Furthermore, the "code" type also accepts two named arguments:

#### :repo

```
# look for modules in "lib" subdirectory as well
my &needle = compile-needle("code" => '.uc', :repo<lib>);

```

Specifies location(s) in which loadable modules should be searched. It is the equivalent of Raku's `-I` command line option, and the `use lib` pragma.

#### :module

```
# Load the "Test" module
my &needle = compile-needle("code" => 'is $_, 42', :module<Test>);

```

Specifies module(s) that should be loaded. It is the equivalent of Raku's `-M` command line option, and the `use` statement.

### contains

```
# accept haystack if it contains "bar"
my &needle = compile-needle("contains" => "bar");

```

Assumes the string is a needle in a call to `.contains`.

### ends-with

```
# accept haystack if it ends with "bar"
my &needle = compile-needle("ends-with" => "bar");

```

Assumes the string is a needle in a call to `.ends-with`.

### equal

```
# accept haystack if it is equal to "bar"
my &needle = compile-needle("equal" => "bar");

```

Assumes the string is a needle to compare with the haystack using infix `eq` semantics.

### file

```
# return result of matching patterns in file "always"
my &needle = compile-needle("file" => 'always');

```

Assumes the given string is a valid path specification, pointing to a file containing the patterns to be used.

The following types of lines will be ignored:

* empty lines
* lines consisting of whitespace only
* lines starting with "#"

Note that the filename `"-"` will be interpreted as "read from STDIN".

### json-path

```
# return result of JSON::Path query "auth"
my &needle = compile-needle("json-path" => 'auth');

```

Assumes the given string is a valid [`JSON Path`](https://en.wikipedia.org/wiki/JSONPath) specification.

Must have the [`JSON::Path`](https://raku.land/cpan:JNTHN/JSON::Path) module installed.

The generated `Callable` will expect an `Associative` haystack (aka, a ) to be passed, and will return a `Slip` with any results.

```
# return result of JSON::Path query "auth"
my &needle = compile-needle({ jp('auth').Slip });

```

Alternately, you can also the `jp()` function. This returns a specialized `JP` object. Note that simply specifying a call to the `jp` function is not enough: one must do something with it. In the above example calling `.Slip` will cause the actual querying to happen.

See "Doing JSON path queries in code needles" for more information.

### not

```
# accept haystack if "bar" is NOT found
my &needle = compile-needle("not" => "bar");

```

This is a meta-type: it inverts the result of the result of matching of the given needle (which can be anything otherwise acceptable).

### regex

```
# accept haystack if "bar" is found
my &needle = compile-needle("regex" => "bar");

```

Assumes the string is a regex specification to be used as a needle in a call to `.contains`.

### split

```
# accept if string contains "foo" *and* "bar"
my &needle = compile-needle("split" => 'foo &bar');

```

This is a meta-type: it splits the given string on whitespace and interpretes the result as a list of needles.

### starts-with

```
# accept haystack if it starts with "bar"
my &needle = compile-needle("starts-with" => "bar");

```

Assumes the string is a needle in a call to `.starts-with`.

### url

```
# accept if any of the needles at given URL matches
my &domain = compile-needle("url" => 'raku.org/robots.txt');
my &url    = compile-needle("url" => 'http://example.com/patterns');

```

Interpretes the given string as a URL from which to obtain the needles from. Assumes `https://` if no protocol is specified.

Requires the `curl` program to be installed and runnable. All protocols supported by `curl` can be used in the URL specification.

### words

```
# accept haystack if "bar" is found as a word
my &needle = compile-needle("words" => "bar");

```

Assumes the string is a needle that will match if the needle is found with word boundaries on either side of the needle.

## Doing JSON path queries in code needles

```
# return result of JSON::Path query "auth"
my &needle = compile-needle("code" => 'jp("auth").Slip');

```

The initial call to the `jp` function will attempt to load the `JSON::Path` module, and fail if it cannot. If the load is successful, it will create an object of the (internal) `JP` class with the giveni pattern.

If the `JSON::Path` module was already loaded, it will either produce the `JP` object from a cache, or create a new `JP` object.

The object as such, does nothing. It needs to have a method called on it **within the scope of the code needle** to properly function.

If you're using the (implicit) `"json-path"` type for your needle, this is done automatically for you, by calling the `.Slip` method on it.

The following methods can be called on the `JP` object:

| method | selected |
| --- | --- |
| .value | The first selected value |
| .values | All selected values as a Seq |
| .paths | The paths of all selected values as a Seq |
| .paths-and-values | Interleaved selected paths and values |
| .words | All words in selected values as a Slip |
| .head | The first N selected values as a Slip |
| .tail | The last N selected values as a Slip |
| .skip | Skip N selected values, produce rest as a Slip |
| .Seq | All selected values as a Seq |
| .Bool | True if any values selected, else False |
| .List | All selected values as a List |
| .Slip | All selected values as a Slip |
| .gist | All selected values stringified as a gist |
| .Str | All selected values stringified |

```
# return first and third result of JSON::Path query "auth" as a Slip
my &needle = compile-needle({ jp('auth')[0,2] });

```

Furthermore, you can use postcircumfix `[ ]` on the `JP` object to select values from the result.

# HELPER SUBROUTINES

## implicit2explicit

```
use Needle::Compile "implicit2explicit";

dd implicit2explicit('foo');    # :contains("foo")
dd implicit2explicit('§bar');   # :words("bar")
dd implicit2explicit('!baz$');  # :not(:ends-with("baz"))

```

The `implicit2explicit` subroutine converts an implicit query specification into an explicit one (expressed as a `Pair` with the key as the type, and the value as the actual string for which to create a needle).

# THEORY OF OPERATION

This module uses the new `RakuAST` classes as much as possible to create an executable `Callable`. This means that until RakuAST supports the complete Raku Programming Language features, it **is** possible that some code will not actually produce a `Callable` needle.

There is not a lot of documentation about RakuAST yet, but there are some blog posts, e.g. [RakuAST for early adopters](https://dev.to/lizmat/rakuast-for-early-adopters-576n).

# AUTHOR

Elizabeth Mattijsen [liz@raku.rocks](mailto:liz@raku.rocks)

Source can be located at: <https://github.com/lizmat/Needle-Compile> . Comments and Pull Requests are welcome.

If you like this module, or what I’m doing more generally, committing to a [small sponsorship](https://github.com/sponsors/lizmat/) would mean a great deal to me!

# COPYRIGHT AND LICENSE

Copyright 2024 Elizabeth Mattijsen

This library is free software; you can redistribute it and/or modify it under the Artistic License 2.0.


## causeonlyvalidonbroken.md
class X::Promise::CauseOnlyValidOnBroken

Error due to asking why an unbroken promise has been broken.

```raku
class X::Promise::CauseOnlyValidOnBroken is Exception { }
```

This exception is thrown when code expects a Promise to be broken, and asks why it has been broken, but the Promise has in fact, not yet been broken.

# [Methods](#class_X::Promise::CauseOnlyValidOnBroken "go to top of document")[§](#Methods "direct link")

## [method promise](#class_X::Promise::CauseOnlyValidOnBroken "go to top of document")[§](#method_promise "direct link")

```raku
method promise()
```

Returns the Promise that was asked about.

## [method status](#class_X::Promise::CauseOnlyValidOnBroken "go to top of document")[§](#method_status "direct link")

```raku
method status()
```

Returns the status the Promise had at that time.


## dist_github-ugexe-Distribution-Common-Remote.md
## Distribution::Common::Remote

Create an installable Distribution from remote sources using the `Distribution::Common` interface

See [Distribution::Common](https://github.com/ugexe/Raku-Distribution--Common) for more information.
This is kept as a separate repo as it requires additional dependencies.

## Synopsis

```
BEGIN %*ENV<GITHUB_ACCESS_TOKEN> = "..."; # optional, but useful due to api rate limiting

use Distribution::Common::Remote::Github;

# Distribution::Common::Remote:auth<github:ugexe>
my $dist = Distribution::Common::Remote::Github.new(
    user    => "ugexe",
    repo    => "Raku-Distribution--Common--Remote",
    branch  => "main"
);

say $dist.meta;
say $dist.content('lib/Distribution/Common/Remote.rakumod').open.slurp-rest;

```

## Classes

### Distribution::Common::Remote::Github

Installable `Distribution` from a github repository

## Roles

### Distribution::IO::Remote::Github

Fetch a single raw file from a distribution's github to memory. When `CompUnitRepository::Installation::Install.install`
accesses such files they are written directly to their install location instead of first using an intermediate temporary
location


## dist_zef-lizmat-P5getprotobyname.md
[![Actions Status](https://github.com/lizmat/P5getprotobyname/workflows/test/badge.svg)](https://github.com/lizmat/P5getprotobyname/actions)

# NAME

Raku port of Perl's getprotobyname() and associated built-ins

# SYNOPSIS

```
use P5getprotobyname;
# exports getprotobyname, getprotobyport, getprotoent, setprotoent, endprotoent

say getprotobynumber(0, :scalar);   # "ip"

my @result_byname = getprotobyname("ip");

my @result_bynumber = getprotobynumber(@result_byname[2]);

```

# DESCRIPTION

This module tries to mimic the behaviour of Perl's `getprotobyname` and associated built-ins as closely as possible in the Raku Programing Language.

It exports by default:

```
endprotoent getprotobyname getprotobynumber getprotoent setprotoent

```

# ORIGINAL PERL 5 DOCUMENTATION

```
getprotobyname NAME
getprotobynumber NUMBER
getprotoent
setprotoent STAYOPEN
endprotoent
        These routines are the same as their counterparts in the system C
        library. In list context, the return values from the various get
        routines are as follows:

         # 0        1          2           3         4
         ( $name,   $aliases,  $proto                ) = getproto*

        In scalar context, you get the name, unless the function was a
        lookup by name, in which case you get the other thing, whatever it
        is. (If the entry doesn't exist you get the undefined value.)

        The "getprotobynumber" function, even though it only takes one
        argument, has the precedence of a list operator, so beware:

            getprotobynumber $number eq 'icmp'   # WRONG
            getprotobynumber($number eq 'icmp')  # actually means this
            getprotobynumber($number) eq 'icmp'  # better this way

```

# PORTING CAVEATS

This module depends on the availability of POSIX semantics. This is generally not available on Windows, so this module will probably not work on Windows.

# AUTHOR

Elizabeth Mattijsen [liz@raku.rocks](mailto:liz@raku.rocks)

If you like this module, or what I’m doing more generally, committing to a [small sponsorship](https://github.com/sponsors/lizmat/) would mean a great deal to me!

Source can be located at: <https://github.com/lizmat/P5getprotobyname> . Comments and Pull Requests are welcome.

# COPYRIGHT AND LICENSE

Copyright 2018, 2019, 2020, 2021, 2023 Elizabeth Mattijsen

Re-imagined from Perl as part of the CPAN Butterfly Plan.

This library is free software; you can redistribute it and/or modify it under the Artistic License 2.0.


## dist_cpan-ALOREN-Canoe.md
An simple thread-safe plug-in framework for Perl 6

# Description

Canoe is an simple plug-in framework for Perl 6. It is thread-safe and
process-safe. The configuration file is base on the JSON format.

# Reference

## Canoe

* e(--> Bool)

  Return True if the configuration file is existed.
* create(--> Promise)

  Create the configuration file with default configuration `{ "plugins": [ ]}`. The `Promise` will kept with True when the file
  created successfully.
* load(--> Promise)

  Return an `Promise` which will kept with all the plug-in.
* Supply(--> Supply)

  Return an `Supply` which will emit every plug-in.
* register(Str $name, Bool $enable --> Promise)

  Register the module `$name` to the current configuration file. The
  `Promise` will kept with True if successfully.
* unregister(Str $name --> Promise)

  Remove the module `$name` from the current configuration file. The
  `Promise` will kept with True if successfully.
* enable(Str $name, --> Promise)

  Enable the plug-in.
* disable(Str $name, --> Promise)

  Disable the plug-in.

## PlugInfo

* has $.enable

  Is True if the plug-in is enabled.
* has $.plugin;

  The type object of current plug-in.
* has $.installed

  Is True if perl6 can find the plug-in in the repository.
* has $.name;

  The name of current plug-in.
* get-instance(\*%\_)

  Create an instance of current plug-in.

# License

```
The MIT License (MIT)

```

# Author

```
araraloren

```


## dist_github-labster-File-Compare.md
# perl6-File-Compare

Compare files, byte-by-byte

Determines if two files are alike or if they differ.

Usage:

```
use File::Compare;

say files_are_equal("file1.txt", "file2.txt");
files_are_different("foo", "bar") ?? say "diff" !! say "same";

say "we match" if files_are_equal("x.png", "y.png",
	chunk_size=> 4*1024*1024);

```

See the pod in Compare.pm for more details.


## lock.md
class Lock

A low-level, re-entrant, mutual exclusion lock

```raku
class Lock {}
```

A `Lock` is a low-level concurrency control construct. It provides mutual exclusion, meaning that only one thread may hold the lock at a time. Once the lock is unlocked, another thread may then lock it.

A `Lock` is typically used to protect access to one or more pieces of state. For example, in this program:

```raku
my $x = 0;
my $l = Lock.new;
await (^10).map: {
    start {
        $l.protect({ $x++ });
    }
}
say $x;         # OUTPUT: «10␤»
```

The `Lock` is used to protect operations on `$x`. An increment is not an atomic operation; without the lock, it would be possible for two threads to both read the number 5 and then both store back the number 6, thus losing an update. With the use of the `Lock`, only one thread may be running the increment at a time.

A `Lock` is re-entrant, meaning that a thread that holds the lock can lock it again without blocking. That thread must unlock the same number of times before the lock can be obtained by another thread (it works by keeping a recursion count).

It's important to understand that there is no direct connection between a `Lock` and any particular piece of data; it is up to the programmer to ensure that the `Lock` is held during all operations that involve the data in question. The `OO::Monitors` module, while not a complete solution to this problem, does provide a way to avoid dealing with the lock explicitly and encourage a more structured approach.

The `Lock` class is backed by operating-system provided constructs, and so a thread that is waiting to acquire a lock is, from the point of view of the operating system, blocked.

Code using high-level Raku concurrency constructs should avoid using `Lock`. Waiting to acquire a `Lock` blocks a real [`Thread`](/type/Thread), meaning that the thread pool (used by numerous higher-level Raku concurrency mechanisms) cannot use that thread in the meantime for anything else.

Any `await` performed while a `Lock` is held will behave in a blocking manner; the standard non-blocking behavior of `await` relies on the code following the `await` resuming on a different [`Thread`](/type/Thread) from the pool, which is incompatible with the requirement that a `Lock` be unlocked by the same thread that locked it. See [`Lock::Async`](/type/Lock/Async) for an alternative mechanism that does not have this shortcoming. Other than that, the main difference is that `Lock` mainly maps to operating system mechanisms, while [`Lock::Async`](/type/Lock/Async) uses Raku primitives to achieve similar effects. If you're doing low-level stuff (native bindings) and/or actually want to block real OS threads, use `Lock`. However, if you want a non-blocking mutual exclusion and don't need recursion and are running code on the Raku thread pool, use Lock::Async.

By their nature, `Lock`s are not composable, and it is possible to end up with hangs should circular dependencies on locks occur. Prefer to structure concurrent programs such that they communicate results rather than modify shared data structures, using mechanisms like [`Promise`](/type/Promise), [`Channel`](/type/Channel) and [`Supply`](/type/Supply).

# [Methods](#class_Lock "go to top of document")[§](#Methods "direct link")

## [method protect](#class_Lock "go to top of document")[§](#method_protect "direct link")

```raku
multi method protect(Lock:D: &code)
```

Obtains the lock, runs `&code`, and releases the lock afterwards. Care is taken to make sure the lock is released even if the code is left through an exception.

Note that the `Lock` itself needs to be created outside the portion of the code that gets threaded and it needs to protect. In the first example below, `Lock` is first created and assigned to `$lock`, which is then used *inside* the [`Promise`](/type/Promise)s to protect the sensitive code. In the second example, a mistake is made: the `Lock` is created right inside the [`Promise`](/type/Promise), so the code ends up with a bunch of separate locks, created in a bunch of threads, and thus they don't actually protect the code we want to protect.

```raku
# Right: $lock is instantiated outside the portion of the
# code that will get threaded and be in need of protection
my $lock = Lock.new;
await ^20 .map: {
    start {
        $lock.protect: {
            print "Foo";
            sleep rand;
            say "Bar";
        }
    }
}

# !!! WRONG !!! Lock is created inside threaded area!
await ^20 .map: {
    start {
        Lock.new.protect: {
            print "Foo"; sleep rand; say "Bar";
        }
    }
}
```

## [method lock](#class_Lock "go to top of document")[§](#method_lock "direct link")

```raku
method lock(Lock:D:)
```

Acquires the lock. If it is currently not available, waits for it.

```raku
my $l = Lock.new;
$l.lock;
```

Since a `Lock` is implemented using OS-provided facilities, a thread waiting for the lock will not be scheduled until the lock is available for it. Since `Lock` is re-entrant, if the current thread already holds the lock, calling `lock` will simply bump a recursion count.

While it's easy enough to use the `lock` method, it's more difficult to correctly use [`unlock`](/type/Lock#method_unlock). Instead, prefer to use the [`protect`](/type/Lock#method_protect) method instead, which takes care of making sure the `lock`/`unlock` calls always both occur.

## [method unlock](#class_Lock "go to top of document")[§](#method_unlock "direct link")

```raku
method unlock(Lock:D:)
```

Releases the lock.

```raku
my $l = Lock.new;
$l.lock;
$l.unlock;
```

It is important to make sure the `Lock` is always released, even if an exception is thrown. The safest way to ensure this is to use the [`protect`](/type/Lock#method_protect) method, instead of explicitly calling `lock` and `unlock`. Failing that, use a `LEAVE` phaser.

```raku
my $l = Lock.new;
{
    $l.lock;
    LEAVE $l.unlock;
}
```

## [method condition](#class_Lock "go to top of document")[§](#method_condition "direct link")

```raku
method condition(Lock:D: )
```

Returns a condition variable as a [`Lock::ConditionVariable`](/type/Lock/ConditionVariable) object. Check [this article](https://web.stanford.edu/~ouster/cgi-bin/cs140-spring14/lecture.php?topic=locks) or [the Wikipedia](https://en.wikipedia.org/wiki/Monitor_%28synchronization%29) for background on condition variables and how they relate to locks and mutexes.

```raku
my $l = Lock.new;
$l.condition;
```

You should use a condition over a lock when you want an interaction with it that is a bit more complex than simply acquiring or releasing the lock.

```raku
constant ITEMS = 100;
my $lock = Lock.new;
my $cond = $lock.condition;
my $todo = 0;
my $done = 0;
my @in = 1..ITEMS;
my @out = 0 xx ITEMS;

loop ( my $i = 0; $i < @in; $i++ ) {
    my $in := @in[$i];
    my $out := @out[$i];
    Thread.start( {
      my $partial = $in² +1;
      if $partial.is-prime {
          $out = $partial but "Prime";
      } else {
          $out = $partial;
      }
      $lock.protect( {
         $done++;
         $cond.signal if $done == $todo;
      } );
    } );
    $todo++;
}
$lock.protect( {
    $cond.wait({  $done == $todo } );
});

say @out.map: { $_.^roles > 2 ?? $_.Num ~ "*" !! $_ };
# OUTPUT: «2* 5* 10 17* 26 37* 50 65 82 101* … »

```

In this case, we use the condition variable `$cond` to wait until all numbers have been generated and checked and also to `.signal` to another thread to wake up when the particular thread is done.

# [Typegraph](# "go to top of document")[§](#typegraphrelations "direct link")

Type relations for `Lock`

raku-type-graph

Lock
Lock

Any
Any

Lock->Any

Mu
Mu

Any->Mu

[Expand chart above](/assets/typegraphs/Lock.svg)


## dist_cpan-JNTHN-OpenAPI-Model.md
# OpenAPI::Model [Build Status](https://travis-ci.org/croservices/openapi-model)

OpenAPI::Model - work with OpenAPI documents in terms of a set of Perl 6 objects.

# SYNOPSIS

```
# Just fully qualified names available (OpenAPI::Model::Operation)
use OpenAPI::Model;
# Or get short names for model objects imported (Operation)
use OpenAPI::Model :elements;

# Load an existing document from YAML (returns OpenAPI::Model::OpenAPI):
my $api = OpenAPI::Model.from-yaml($yaml-doc);
# Or from JSON:
my $api = OpenAPI::Model.from-json($json-doc);

# Dig into the document (automatically resolves references within the
# document):
for $api.paths.kv -> $path, $object {
    say "At $path you can:";
    for <get post put delete> -> $method {
        with $object."$method"() {
            say " - do a $method.uc() request";
        }
    }
}

# References to external schemas are also possible (we won't go trying
# to download anything for you, and expect an `OpenAPI::Model::OpenAPI`
# instance for each one). These are used to resolve external references.
my %external = 'http://some.organization/schema/foobar' =>
    OpenAPI::Model.from-yaml(slurp('foobar.yaml'));
my $api = OpenAPI::Model.from-yaml($yaml-doc, :%external);

```

# DESCRIPTION

OpenAPI::Model is a library that provides Perl 6 object layers upon OpenAPI documents.

# AUTHOR

Alexander Kiryuhin [alexander.kiryuhin@gmail.com](mailto:alexander.kiryuhin@gmail.com)

# COPYRIGHT AND LICENSE

Copyright 2018 Edument Central Europe sro.

This library is free software; you can redistribute it and/or modify it under the Artistic License 2.0.


## dist_zef-martimm-Gnome-GdkPixbuf.md
![](https://martimm.github.io/gnome-gtk3/content-docs/images/gtk-perl6.png)

# Gnome GdkPixbuf

![Artistic License 2.0](https://martimm.github.io/label/License-label.svg)

# Description

## Documentation

* [🔗 Website, entry point for all documents and blogs](https://martimm.github.io/)
* [🔗 License document](https://www.perlfoundation.org/artistic_license_2_0)
* [🔗 Release notes of all the packages in `:api<2>`](https://github.com/MARTIMM/gnome-source-skim-tool/blob/main/CHANGES.md)
* [🔗 Issues of all the packages in `:api<2>`](https://github.com/MARTIMM/gnome-source-skim-tool/issues)

# Installation

Do not install this package on its own. Instead install `Gnome::Gtk4` newest api.

`zef install Gnome::Gtk4:api<2>`

# Author

Name: **Marcel Timmerman**
Github account name: **MARTIMM**

# Issues

There are always some problems! If you find one please help by filing an issue at [my github project](https://github.com/MARTIMM/gnome-source-skim-tool/issues).

# Attribution

* The inventors of Raku, formerly known as Perl 6, of course and the writers of the documentation which helped me out every time again and again.
* The builders of all the Gnome libraries and the documentation.
* Other helpful modules for their insight and use.


## dist_zef-lizmat-Random-Names.md
[![Actions Status](https://github.com/lizmat/Random-Names/actions/workflows/linux.yml/badge.svg)](https://github.com/lizmat/Random-Names/actions) [![Actions Status](https://github.com/lizmat/Random-Names/actions/workflows/macos.yml/badge.svg)](https://github.com/lizmat/Random-Names/actions) [![Actions Status](https://github.com/lizmat/Random-Names/actions/workflows/windows.yml/badge.svg)](https://github.com/lizmat/Random-Names/actions)

# NAME

Random::Names - Create random names to be used as identifiers

# SYNOPSIS

```
use Random::Names;

# procedural interface
say docker-name;      # e.g. epic-engelbart
say class-name;       # e.g. Mendeleev
say identifier-name;  # e.g. dhawan

my @dn = docker-name(10);      # get array with 10 unique docker-names
my @cn = class-name(10);       # get array with 10 unique class-names
my @in = identifier-name(10);  # get array with 10 unique identifiers

# object interface
my $rn = Random::Names.new;  # set up unique pool of names
say $rn.docker-name;
say $rn.class-name;
say $rn.identifier-name;

```

# DESCRIPTION

Sometimes you need some placeholder names for things that do not have a name yet. This module provides a way to create names for things that are both fun and interesting. The names from which it selects, are the surnames of individuals that are famous in the history of scientific exploration and engineering.

It offers 3 types of random names:

* docker-name

Similar to how Docker names unnamed containers.

* class-name

Title-cased names used for classes in Raku.

* identifier-name

Just a random name that can be used as an identifier.

This module also installs a `rn` script that allows you to generate one or more names, accepting a named argument `--docker` for docker names, `--class` for class names, or just identifiers if not specified. Also optionally takes a named argument `--verbose` to also show the `WHY` and `LINK` information.

# ADDITIONAL INFORMATION

Each string that is being returned by this module, also has a `.WHY` method attached to it that will give additional information about the person to which the name is attached. E.g.;

```
my $name = identifier-name;
say $name;  # einstein
my $why = $name.WHY;
say $why;  # Albert Einstein invented the general theory of relativity.

```

And that string has a `.LINK` method that produces a link to a page that will show you more information about that person:

```
say $why.LINK;  # https://en.wikipedia.org/wiki/Albert_Einstein

```

# FUNCTIONS

## docker-name

Return a random string similar to how Docker names unnamed containers, such as: `interesting-mendeleev`, `epic-engelbart`, `lucid-dhawan`, `recursing-cori`, `ecstatic-liskov` and `busy-ardinghelli`. These are made from a random selection of an adjective and a surname.

Optionally takes the number of docker-names to be returned.

```
say docker-name;          # e.g. epic-engelbart
.say for docker-name(5);  # 5 different docker names

```

## class-name

Return a random string that can be used as a name of a class, such as *Mendeleev*.

Optionally takes the number of class names to be returned.

```
say class-name;          # e.g. Engelbart
.say for class-name(5);  # 5 different class names

```

## identifier-name

Return a random string that can be used as an identifier, such as *dhawan*.

Optionally takes the number of identifiers to be returned.

```
say identifier-name;          # e.g. cori
.say for identifier-name(5);  # 5 different identifiers

```

# METHODS

The method interface has two different modes of operation. When called as a class method, the semantics are exactly the same as the functional interface.

When called on a `Random::Names` instance, it will only produce each adjective and each surname **only once**. This means that any mix of calls to `docker-name`, `class-name` or `identifier-name`, the returned strings will always be unique.

## new

```
my $rn = Random::Names.new:
  adjectives => <pretty awful>,     # default: standard set of adjectives
  surnames   => <mattijsen kasik>,  # default: standard set of surnames
;

```

## docker-name

Return a random string similar to how Docker names unnamed containers. These are made from a random selection of an adjective and a surname.

Optionally takes the number of docker-names to be returned.

```
my $rn = Random::Names.new;
say $rn.docker-name;          # e.g. epic-engelbart
.say for $rn.docker-name(5);  # 5 different docker names

```

## class-name

Return a random string that can be used as a name of a class, such as *Mendeleev*.

Optionally takes the number of class names to be returned.

```
my $rn = Random::Names.new;
say $rn.class-name;          # e.g. Engelbart
.say for $rn.class-name(5);  # 5 different class names

```

## identifier-name

Return a random string that can be used as an identifier, such as *dhawan*.

Optionally takes the number of identifiers to be returned.

```
my $rn = Random::Names.new;
say $rn.identifier-name;          # e.g. cori
.say for $rn.identifier-name(5);  # 5 different identifiers

```

## adjectives

```
.say for Random::Names.new.adjectives;

```

Return an array of possible adjectives, alphabetically sorted.

## surnames

```
.say for Random::Names.new.surnames;

```

Return an array of possible surnames, alphabetically sorted.

# AUTHOR

Elizabeth Mattijsen [liz@raku.rocks](mailto:liz@raku.rocks), inspired by the Perl module `Data::Docker::Names` by Mikko Johannes Koivunalho [mikko.koivunalho@iki.fi](mailto:mikko.koivunalho@iki.fi).

Source can be located at: <https://github.com/lizmat/Random-Names> . Comments and Pull Requests are welcome.

If you like this module, or what I’m doing more generally, committing to a [small sponsorship](https://github.com/sponsors/lizmat/) would mean a great deal to me!

# COPYRIGHT AND LICENSE

Copyright 2020, 2021, 2022, 2025 Elizabeth Mattijsen

This library is free software; you can redistribute it and/or modify it under the Artistic License 2.0.


## dist_zef-dwarring-CSS-Grammar.md
[[Raku CSS Project]](https://css-raku.github.io)
/ [[CSS-Grammar Module]](https://css-raku.github.io/CSS-Grammar-raku)

# CSS-Grammar-raku

CSS::Grammar is a set of Raku grammars for the W3C family of CSS standards.

It aims to implement a reasonable portion of the base grammars with an
emphasis on:

* support for CSS1, CSS2.1 and CSS3
* forward compatibility rules, scanning and error recovery

This module performs generic parsing of declarations in style-sheet rules.

# Contents

## Base Grammars

* `CSS::Grammar::CSS1` - CSS 1.0 compatible grammar
* `CSS::Grammar::CSS21` - CSS 2.1 compatible grammar
* `CSS::Grammar::CSS3` - CSS 3.0 (core) compatible grammar

The CSS 3.0 core grammar, `CSS::Grammar::CSS3`, is based on CSS2.1; it understands:

* `#hex` and `rgb(...)` colors; but not `rgba(..)`, `hsl(...)`, `hsla(...)` or named colors
* basic `@media` at-rules; but not advanced media queries, resolutions or embedded `@page` rules.
* basic `@page` page description rules
* basic css3 level selectors

## Parser Actions

`CSS::Grammar::Actions` can be used with in conjunction with any of the CSS1
CSS21 or CSS3 base grammars. It produces an abstract syntax tree (AST), plus
warnings for any unexpected input.

```
use v6;
use CSS::Grammar::CSS3;
use CSS::Grammar::Actions;

my $css = 'H1 { color: blue; gunk }';

my $actions =  CSS::Grammar::Actions.new;
my $p = CSS::Grammar::CSS3.parse($css, :actions($actions));
.note for $actions.warnings;
say "H1: " ~ $p.ast<stylesheet>[0]<ruleset><selectors>;
# output:
# dropping term: gunk
# H1: selector    simple-selector qname   element-name    h1

```

## Actions Options

* **`:lax`** Pass back, don't drop, quantities with unknown dimensions.

## Installation

You can use the Raku `zef` module installer to test and install `CSS::Grammar`:

```
% zef install CSS::Grammar

```

To try parsing some content:

```
% raku -MCSS::Grammar::CSS3 -e"say CSS::Grammar::CSS3.parse('H1 {color:blue}')"

```

## See Also

* [CSS::Properties](https://css-raku.github.io/CSS-Properties-raku) CSS Propery-list manipulation library.
* [CSS](https://css-raku.github.io/CSS-raku) CSS Stylesheets and processing.
* [CSS::Module::CSS3::Selectors](https://css-raku.github.io/CSS-Module-CSS3-Selectors-raku) extends CSS::Grammar::CSS3 to fully implement CSS Level 3 Selectors.
* [CSS::Module](https://css-raku.github.io/CSS-Module-raku) further extends CSS::Grammar levels 1, 2.1 and 3. It understands named colors and is able to perform property-specific parsing and validation.
* [CSS::Writer](https://css-raku.github.io/CSS-Writer-raku) - AST reserializer
* [CSSGrammar.pm](https://github.com/Raku/examples/blob/master/categories/parsers/CSSGrammar.pm) from [Raku/examples](https://github.com/Raku/examples) gives an introductory Raku grammar for CSS 2.1.

## References

This module been built from the W3C CSS Specifications. In particular:

* CSS 1.0 Grammar - <http://www.w3.org/TR/2008/REC-CSS1-20080411/#appendix-b>
* CSS 2.1 Grammar - <http://www.w3.org/TR/CSS21/grammar.html>
* CSS3 module: Syntax - <http://www.w3.org/TR/2014/CR-css-syntax-3-20140220/>
* CSS Style Attributes - <http://www.w3.org/TR/2010/CR-css-style-attr-20101012/#syntax>


## dist_cpan-TIMOTIMO-JSON-Fast.md
[![Build Status](https://travis-ci.org/timo/json_fast.svg?branch=master)](https://travis-ci.org/timo/json_fast)

# JSON::Fast

A naive imperative JSON parser in pure Raku (but with direct access to `nqp::` ops), to evaluate performance against `JSON::Tiny`. It is a drop-in replacement for `JSON::Tiny`’s from-json and to-json subs, but it offers a few extra features.

Currently it seems to be about 4x faster and uses up about a quarter of the RAM JSON::Tiny would use.

This module also includes a very fast to-json function that tony-o created and lizmat later completely refactored.

## Exported subroutines

### to-json

```
    my $*JSON_NAN_INF_SUPPORT = 1; # allow NaN, Inf, and -Inf to be serialized.
    say to-json [<my Raku data structure>];
    say to-json [<my Raku data structure>], :!pretty;
    say to-json [<my Raku data structure>], :spacing(4);

enum Blerp <Hello Goodbye>;
say to-json [Hello, Goodbye]; # ["Hello", "Goodbye"]
say to-json [Hello, Goodbye], :enums-as-value; # [0, 1]

```

Encode a Raku data structure into JSON. Takes one positional argument, which is a thing you want to encode into JSON. Takes these optional named arguments:

#### pretty

`Bool`. Defaults to `True`. Specifies whether the output should be "pretty", human-readable JSON. When set to false, will output json in a single line.

#### spacing

`Int`. Defaults to `2`. Applies only when `pretty` is `True`. Controls how much spacing there is between each nested level of the output.

#### sorted-keys

Specifies whether keys from objects should be sorted before serializing them to a string or if `$obj.keys` is good enough. Defaults to `False`. Can also be specified as a `Callable` with the same type of argument that the `.sort` method accepts to provide alternate sorting methods.

#### enum-as-value

`Bool`, defaults to `False`. Specifies whether `enum`s should be json-ified as their underlying values, instead of as the name of the `enum`.

### from-json

```
    my $x = from-json '["foo", "bar", {"ber": "bor"}]';
    say $x.perl;
    # outputs: $["foo", "bar", {:ber("bor")}]

```

Takes one positional argument that is coerced into a `Str` type and represents a JSON text to decode. Returns a Raku datastructure representing that JSON.

#### immutable

`Bool`. Defaults to `False`. Specifies whether `Hash`es and `Array`s should be rendered as immutable datastructures instead (as `Map` / `List`. Creating an immutable data structures is mostly saving on memory usage, and a little bit on CPU (typically around 5%).

This also has the side effect that elements from the returned structure can now be iterated over directly because they are not containerized.

#### allow-jsonc

`BOOL`. Defaults to `False`. Specifies whether commmands adhering to the [JSONC standard](https://changelog.com/news/jsonc-is-a-superset-of-json-which-supports-comments-6LwR) are allowed.

```
    my %hash := from-json "META6.json".IO.slurp, :immutable;
    say "Provides:";
    .say for %hash<provides>;

```

## Additional features

### Adapting defaults of "from-json"

In the `use` statement, you can add the string `"immutable"` to make the default of the `immutable` parameter to the `from-json` subroutine `True`, rather than False.

```
    use JSON::Fast <immutable>;  # create immutable data structures by default

```

### Adapting defaults of "to-json"

In the `use` statement, you can add the strings `"!pretty"`, `"sorted-keys"` and/or `"enums-as-value"` to change the associated defaults of the `to-json` subroutine.

```
    use JSON::FAST <!pretty sorted-keys enums-as-value>;

```

### Strings containing multiple json pieces

When the document contains additional non-whitespace after the first successfully parsed JSON object, JSON::Fast will throw the exception `X::JSON::AdditionalContent`. If you expect multiple objects, you can catch that exception, retrieve the parse result from its `parsed` attribute, and remove the first `rest-position` characters off of the string and restart parsing from there.


## bless.md
bless

Combined from primary sources listed below.

# [In Mu](#___top "go to top of document")[§](#(Mu)_method_bless "direct link")

See primary documentation
[in context](/type/Mu#method_bless)
for **method bless**.

```raku
method bless(*%attrinit --> Mu:D)
```

Low-level object construction method, usually called from within `new`, implicitly from the default constructor, or explicitly if you create your own constructor. `bless` creates a new object of the same type as the invocant, using the named arguments to initialize attributes and returns the created object.

It is usually invoked within custom `new` method implementations:

```raku
class Point {
    has $.x;
    has $.y;
    multi method new($x, $y) {
        self.bless(:$x, :$y);
    }
}
my $p = Point.new(-1, 1);

```

In this example we are declaring this `new` method to avoid the extra syntax of using pairs when creating the object. `self.bless` returns the object, which is in turn returned by `new`. `new` is declared as a `multi method` so that we can still use the default constructor like this: `Point.new( x => 3, y => 8 )`.

For more details see [the documentation on object construction](/language/objects#Object_construction).


## dist_zef-thundergnat-Rat-Precise.md
[![Actions Status](https://github.com/thundergnat/Rat-Precise/actions/workflows/test.yml/badge.svg)](https://github.com/thundergnat/Rat-Precise/actions)

# NAME

Rat::Precise

# SYNOPSIS

Stringify Rats to a configurable precision.

Provides a Rational method .precise. Pass in a positive integer to set places of precision. Pass in a boolean flag :z to preserve trailing zeros.

```
use Rat::Precise;

my $rat = 2213445/437231;

say $rat;                 # 5.0624155
say $rat.precise;         # 5.0624155194851234
say $rat.FatRat.precise;  # 5.06241551948512342445983930691099
say $rat.precise(37);     # 5.06241551948512342445983930691099213
say $rat.precise(37, :z); # 5.0624155194851234244598393069109921300
say $rat.precise(0);      # 5

# terminating Rats
say (1.5**63).Str;     # 124093581919.64894769782737365038
say (1.5**63).precise; # 124093581919.648947697827373650380188008224280338254175148904323577880859375

```

# DESCRIPTION

The default Rat stringification routines are a fairly conservative tradeoff between speed and precision. This module shifts hard to the precision side at the expense of speed.

Augments Rat and FatRat classes with a .precise method. Stringifies configurably to a more precise representation than default .Str methods.

The .precise method can accept two parameters. A positive integer to specify the number of places of precision after the decimal, and/or a boolean flag to control whether non-significant zeros are trimmed.

In base 10, Rational fractions with denominators that are a power of 2 or 5 will terminate.

By default, the precise method stringifies terminating fractions completely. If the fraction is non-terminating, Rats return at least 16 places of precision, FatRats return at least 32 places. Any trailing zeros are trimmed.

If an integer parameter is passed, the fractional portion will be calculated to that many digits, but may have non-significant digits trimmed. The integer must be non negative. Negative integers will be ignored. It can be zero, and it will return zero fractional digits, but it would be much more efficient to just Int the Rat.

If a :z flag is passed, trailing (non-significant) zeros will be preserved.

Parameters can be in any order and combination.

Note that the .precise method only affects stringification. It doesn't change the internal representations of the Rationals, nor does it make calculations any more precise. It is merely a shortcut to express Rational strings to a configurable specified precision.

The :z flag is mostly intended to be used in combination with a digits parameter. It may be used on its own, but may return slightly non-intuitive results. In order to save unnecessary calculations (and speed up the overall process) the .precise method only checks for terminating fractions that are multiples of 2 & 5 less than 10. To avoid lots of pointless checks and general slowdown, any terminating fraction that is a multiple of 10 or above will be calculated out to the default precision (16 digits for Rats, 32 for FatRats or the number of characters in the denominator if that is greater) since it will terminate within that precision.

The point is, if you want to keep trailing zeros, you are better off specifying digits of precision also.

# AUTHOR

2018 Steve Schulze aka thundergnat

This package is free software and is provided "as is" without express or implied warranty. You can redistribute it and/or modify it under the same terms as Perl itself.

# LICENSE

Licensed under The Artistic 2.0; see LICENSE.


## dist_cpan-GARLANDG-Universal-errno.md
# NAME

Universal::errno - Wrapper for errno modules for Unix and Windows

# SYNOPSIS

```
use Universal::errno;

  set_errno(2);

  say errno;
  say "failed: {errno}";
  say +errno;              #2

```

# DESCRIPTION

Universal::errno is an extension of and wrapper around lizmat's `Unix::errno`, and exports the same `errno` and `set_errno` interface. It works on Linux, Windows, and Macos. BSD support is untested, but should work.

One added feature is the `strerror` method, which gets the string for the error in a thread-safe way. On platforms that support it, it uses POSIX `strerror_l`. This allows getting the error string that corresponds to the user's set locale. On platforms that don't support it, strerror\_r (XSI) is used. On Windows, this is done using `GetLastError()` and `FormatMessageW`. Windows also has a `SetLastError` function which is used instead of masking the value.

This module provides an Exception class, X::errno. To check the type of error in a portable way, use the `symbol` method and smartmatch against an entry in the Errno enum.

It also provides a trait: error-model. Mark a sub or method with `is error-model<errno>` and the trait will automatically box the errno for you and reset errno to 0.

Important note: With a native sub, the `is native` trait must come before `is error-model`.

For calls that return `-errno`, there is also the trait `is error-model<neg-errno>`.

If high-performance is needed for a native sub that can return errno, use the `check-errno` and/or `check-neg-errno` subs. These subs are interchangeable with the traits, but cannot be directly applied to a nativecall subroutine.

As an example of a real-world scenario, this code sets up a socket using socket(2) and handles the errors with a CATCH block.

```
use NativeCall;
use Constants::Sys::Socket;

sub socket(int32, int32, int32) returns int32 is native is error-model<errno> { ... }
my int32 $socket;

try {
  $socket = socket(AF::INET, SOCK_DGRAM, 0);

  # Do something with $socket

  CATCH {
    when X::errno {
      given .symbol {
        when Errno::EINVAL {
          die "Invalid socket type"
        }
        when Errno::EACCES {
          die "Permission denied"
        }
        ...
      }
    }
  }
}

```

## class X::errno

Exception class for errno

### method message

```
method message() returns Mu

```

Get the Str message for this errno value.

### method symbol

```
method symbol() returns Mu

```

Get the symbol of this errno value.

### method Int

```
method Int() returns Mu

```

Get the integer that corresponds to this errno value.

# Subs

### sub check-neg-errno

```
sub check-neg-errno(
    Int $result
) returns Mu

```

Check the result against the negative errno form.

### sub check-errno

```
sub check-errno(
    Int $result
) returns Mu

```

Check the result against the errno() form.

# AUTHOR

Travis Gibson [TGib.Travis@protonmail.com](mailto:TGib.Travis@protonmail.com)

## CREDIT

Uses a heavily-modified `Unix::errno` module for Unix-like OSes, and uses `Windows::errno` (also based on lizmat's `Unix::errno`) for Windows OSes.

Universal::errno::Unix contains all of the modified code, and this README also borrows the SYNOPSIS example above. The original README and COPYRIGHT information for lizmat's `Unix::errno` has been preserved in `Universal::errno::Unix`.

lizmat's `Unix::errno` can be found at <https://github.com/lizmat/Unix-errno>

# COPYRIGHT AND LICENSE

Copyright 2020 Travis Gibson

This library is free software; you can redistribute it and/or modify it under the Artistic License 2.0.


## dist_zef-raku-community-modules-Git-Log.md
[![Actions Status](https://github.com/raku-community-modules/Git-Log/actions/workflows/linux.yml/badge.svg)](https://github.com/raku-community-modules/Git-Log/actions) [![Actions Status](https://github.com/raku-community-modules/Git-Log/actions/workflows/macos.yml/badge.svg)](https://github.com/raku-community-modules/Git-Log/actions) [![Actions Status](https://github.com/raku-community-modules/Git-Log/actions/workflows/windows.yml/badge.svg)](https://github.com/raku-community-modules/Git-Log/actions)

# NAME

Git::Log - Gets the git log as a Raku object

# SYNOPSIS

Gets the git log as a Raku object

# DESCRIPTION

The first argument is the command line args wanted to be passed into `git log`. Optionally you can also get the files changes as well as the number of lines added or deleted.

Returns an array of hashes in the following format: `ID => "df0c229ad6ba293c67724379bcd3d55af6ea47a0", AuthorName => "Author's Name", AuthorEmail => "sample.email@not-a.url" ...`

If the option :get-changes is used (off by default) it will also add a 'changes' key in the following format: `changes => { $[ { filename => 'myfile.txt', added => 10, deleted => 5 }, ... ] }`

If there is a field that you need that is not offered, then you can supply an array, :@fields. Format is an array of pairs: `ID => '%H', AuthorName => '%an' ...` you can look for more [here](https://git-scm.com/docs/pretty-formats).

These are the default fields:

```
my @fields-default =
  ID          => '%H',
  AuthorName  => '%an',
  AuthorEmail => '%ae',
  AuthorDate  => '%aI',
  Subject     => '%s',
  Body        => '%b'
;

```

# EXAMPLES

```
# Gets the git log for the specified repository,
# from versions 2018.06 to main
git-log(:path($path.IO), '2018.06..main')

# Gets the git log for the current directory, and does I<not> get the files
# changed in that commit
git-log(:!get-changes)

```

### sub git-log

```
sub git-log(
    *@args,
    :@fields = Code.new,
    IO::Path :$path,
    Bool:D :$get-changes = Bool::False,
    Bool:D :$date-time = Bool::False
) returns Mu

```

git-log's first argument is an array that is passed to C and optionally you can provide a path so a directory other than the current are used.

# AUTHOR

Samantha McVey

Source can be located at: <https://github.com/raku-community-modules/Git-Log> . Comments and Pull Requests are welcome.

# COPYRIGHT AND LICENSE

Copyright 2018 Samantha McVey

Copyright 2024 The Raku Community

This library is free software; you can redistribute it and/or modify it under the Artistic License 2.0.