Aion

 view release on metacpan or  search on metacpan

i18n/Aion/Meta/Feature.ru-en.po  view on Meta::CPAN

"The serial number of the feature in the class."

msgid "## required (;$bool)\n"
"Флаг обязательности фичи в конструкторе (`new`)."
msgstr "## required (;$bool)\n"
"Flag for requiring a feature in the constructor (`new`)."

msgid "## excessive (;$bool)\n"
"Флаг избыточности фичи в конструкторе (`new`). Если она там есть должно выбрасываться исключение."
msgstr "## excessive (;$bool)\n"
"Feature redundancy flag in the constructor (`new`). If it is there, an exception should be thrown."

msgid "## isa (;Object[Aion::Type])\n"
"Ограничение типа для значения фичи."
msgstr "## isa (;Object[Aion::Type])\n"
"Type constraint on feature value."

msgid "## lazy (;$bool)\n"
"Флаг ленивой инициализации."
msgstr "## lazy (;$bool)\n"
"Lazy initialization flag."

i18n/Aion/Meta/Subroutine.ru-en.po  view on Meta::CPAN

msgid "А так же создаёт функцию-обёртку проверяющую сигнатуру."
msgstr "It also creates a wrapper function that checks the signature."

msgid "Конструктор."
msgstr "Constructor."

msgid "Создаёт функцию-обёртку проверяющую сигнатуру."
msgstr "Creates a wrapper function that checks the signature."

msgid "Сверяет свою (ожидаемую) сигнатуру с объявленной у функции в модуле и выбрасывает исключение, если сигнатуры не совпадают."
msgstr "Checks its (expected) signature against the one declared by the function in the module and throws an exception if the signatures do not match."

msgid "Строковое описание функции."
msgstr "String description of the function."

msgid "Возвращает имя пакета, в котором объявлена функция."
msgstr "Returns the name of the package in which the function is declared."

msgid "Возвращает имя функции."
msgstr "Returns the name of the function."

i18n/Aion/Type.ru-en.po  view on Meta::CPAN

msgid "Проверяет, что аргумент не принадлежит классу."
msgstr "Checks that the argument does not belong to the class."

msgid "Привести `$value` к типу, если приведение из типа и функции находится в `$self->{coerce}`."
msgstr "Cast `$value` to type if the cast from type and function is in `$self->{coerce}`."

msgid "Формирует сообщение ошибки."
msgstr "Generates an error message."

msgid "Проверяет `$element` и выбрасывает сообщение `detail`, если элемент не принадлежит классу."
msgstr "Checks `$element` and throws a `detail` message if the element does not belong to the class."

msgid "Переводит `$val` в строку."
msgstr "Converts `$val` to a string."

msgid "Определяет, что тип является подтипом другого `$type`."
msgstr "Specifies that a type is a subtype of another `$type`."

msgid "Создаёт подпрограмму без аргументов, которая возвращает тип."
msgstr "Creates a subroutine with no arguments that returns a type."

msgid "Свойство `init` не может использоваться с `make`."
msgstr "The `init` property cannot be used with `make`."

msgid "Создает подпрограмму с аргументами, которая возвращает тип."
msgstr "Creates a subroutine with arguments that returns a type."

msgid "Если подпрограмма не может быть создана, то выбрасывается исключение."
msgstr "If the routine cannot be created, an exception is thrown."

msgid "Типы равны, если они имеют одинаковое имя, одинаковое количество аргументов, родительский элемент и аргументы равны."
msgstr "Types are equal if they have the same name, the same number of arguments, the parent element, and the arguments are equal."

msgid "Обратная операция к `equal`."
msgstr "The reverse operation of `equal`."

msgid "Список аргументов."
msgstr "List of arguments."

i18n/Aion/Types.ru-en.po  view on Meta::CPAN

msgid "Используется с `subtype` для вывода сообщения об ошибке, если значение исключает тип. В `$code` используется: `SELF` - текущий тип, `ARGS`, `A`, `B`, `C`, `D...
msgstr "Used with `subtype` to print an error message if the value excludes the type. `$code` uses: `SELF` - the current type, `ARGS`, `A`, `B`, `C`, `D` - type arguments (if any) and a test value in `$_`. It can be converted to a string using `SELF-...

msgid "Добавляет новое приведение (`$via`) к `$type` из `$from` типа."
msgstr "Adds a new cast (`$via`) to `$type` from `$from` type."

msgid "Может использовать параметры типа:"
msgstr "Can use parameters like:"

msgid "`coerce` выбрасывает исключения:"
msgstr "`coerce` throws exceptions:"

msgid "Стандартные приведения:"
msgstr "Standard casts:"

msgid "Синтаксический сахар для `coerce`."
msgstr "Syntactic sugar for `coerce`."

msgid "Проверяет сигнатуру подпрограммы: аргументы и результаты."
msgstr "Checks the signature of a subroutine: arguments and results."

lib/Aion/Meta/Feature.pm  view on Meta::CPAN


=head2 required (;$bool)

Flag for requiring a feature in the constructor (C<new>).

	$::feature->required(1);
	$::feature->required # -> 1

=head2 excessive (;$bool)

Feature redundancy flag in the constructor (C<new>). If it is there, an exception should be thrown.

	$::feature->excessive(1);
	$::feature->excessive # -> 1

=head2 isa (;Object[Aion::Type])

Type constraint on feature value.

	use Aion::Type;
	

lib/Aion/Meta/Subroutine.pm  view on Meta::CPAN

=head2 new (%args)

Constructor.

=head2 wrap_sub ()

Creates a wrapper function that checks the signature.

=head2 compare ($subroutine)

Checks its (expected) signature against the one declared by the function in the module and throws an exception if the signatures do not match.

=head2 stringify ()

String description of the function.

=head2 pkg ()

Returns the name of the package in which the function is declared.

=head2 subname ()

lib/Aion/Type.pm  view on Meta::CPAN

	my $Num = Aion::Type->new(name => "Num", message => sub {
		"Error: $_ is'nt $Aion::Type::SELF->{N}!"
	});
	
	$Num->detail("x", "car") # => Error: x is'nt car!

C<< $Aion::Type::SELF-E<gt>{N} >> equivalent to C<N> in context of C<Aion::Types>.

=head2 validate ($element, $feature)

Checks C<$element> and throws a C<detail> message if the element does not belong to the class.

	my $PositiveInt = Aion::Type->new(
		name => "PositiveInt",
		test => sub { /^\d+$/ },
	);
	
	eval {
		$PositiveInt->validate(-1, "Neg")
	};
	$@ # ~> Neg must have the type PositiveInt. The it is -1

lib/Aion/Type.pm  view on Meta::CPAN

	BEGIN {
		Aion::Type->new(name=>"Rim", test => sub { /^[IVXLCDM]+$/i })->make(__PACKAGE__);
	}
	
	"IX" ~~ Rim	 # => 1

The C<init> property cannot be used with C<make>.

	eval { Aion::Type->new(name=>"Rim", init => sub {...})->make(__PACKAGE__) }; $@ # ~> init_where won't work in Rim

If the routine cannot be created, an exception is thrown.

	eval { Aion::Type->new(name=>"Rim")->make }; $@ # ~> syntax error

=head2 make_arg ($pkg)

Creates a subroutine with arguments that returns a type.

	BEGIN {
		Aion::Type->new(name=>"Len", test => sub {
			$Aion::Type::SELF->{args}[0] <= length($_) && length($_) <= $Aion::Type::SELF->{args}[1]
		})->make_arg(__PACKAGE__);
	}
	
	"IX" ~~ Len[2,2] # => 1

If the routine cannot be created, an exception is thrown.

	eval { Aion::Type->new(name=>"Rim")->make_arg }; $@ # ~> syntax error

=head2 make_maybe_arg ($pkg)

Creates a subroutine with arguments that returns a type.

	BEGIN {
		Aion::Type->new(
			name => "Enum123",
			test => sub { $_ ~~ [1,2,3] },
			a_test => sub { $_ ~~ $Aion::Type::SELF->{args} },
		)->make_maybe_arg(__PACKAGE__);
	}
	
	3 ~~ Enum123        # -> 1
	3 ~~ Enum123[4,5,6] # -> ""
	5 ~~ Enum123[4,5,6] # -> 1

If the routine cannot be created, an exception is thrown.

	eval { Aion::Type->new(name=>"Rim")->make_maybe_arg }; $@ # ~> syntax error

=head2 equal ($type)

Types are equal if they have the same name, the same number of arguments, the parent element, and the arguments are equal.

	my $Int = Aion::Type->new(name => "Int");
	my $PositiveInt = Aion::Type->new(name => "PositiveInt", as => $Int);
	my $AnotherInt = Aion::Type->new(name => "Int");

lib/Aion/Types.pm  view on Meta::CPAN


	BEGIN {
		subtype 'Plus[acc]', as Num;
	}
	coerce &Plus, from Num, via { $_ + A };
	
	Plus([5])->coerce(4) # -> 9
	Plus([5]) >> 5 # -> 10
	1 >> Plus[5] # -> 6

C<coerce> throws exceptions:

	eval {coerce Int, via1 => 1}; $@  # ~> coerce Int unused keys left: via1
	eval {coerce "x"}; $@  # ~> coerce x not Aion::Type!
	eval {coerce Int}; $@  # ~> coerce Int: from is'nt Aion::Type!
	eval {coerce Int, from "x"}; $@  # ~> coerce Int: from is'nt Aion::Type!
	eval {coerce Int, from Num}; $@  # ~> coerce Int: via is not subroutine!
	eval {coerce Int, (from=>Num, via=>"x")}; $@  # ~> coerce Int: via is not subroutine!

Standard casts:



( run in 2.189 seconds using v1.01-cache-2.11-cpan-f56aa216473 )