| 1 | # | ||
| 2 | # Copyright (c) 2019-2020 Christian Jaeger, copying@christianjaeger.ch | ||
| 3 | # | ||
| 4 | # This is free software, offered under either the same terms as perl 5 | ||
| 5 | # or the terms of the Artistic License version 2 or the terms of the | ||
| 6 | # MIT License (Expat version). See the file COPYING.md that came | ||
| 7 | # bundled with this file. | ||
| 8 | # | ||
| 9 | |||
| 10 | =head1 NAME | ||
| 11 | |||
| 12 | FP::Interfaces - implement interfaces | ||
| 13 | |||
| 14 | =head1 SYNOPSIS | ||
| 15 | |||
| 16 | See the synopsis of L<FP::Interface> for how to define an interface. | ||
| 17 | |||
| 18 | { | ||
| 19 | package Foo; | ||
| 20 | use FP::Interfaces; | ||
| 21 | |||
| 22 | sub foo { } | ||
| 23 | sub fold { } | ||
| 24 | |||
| 25 | FP::Interfaces::implemented qw(FP::Abstract::ExtendedSequence | ||
| 26 | FP::Abstract::Pure); | ||
| 27 | } | ||
| 28 | |||
| 29 | =head1 DESCRIPTION | ||
| 30 | |||
| 31 | This is just a wrapper around L<FP::Interface> to allow for multiple | ||
| 32 | arguments and read as proper english. | ||
| 33 | |||
| 34 | =head1 SEE ALSO | ||
| 35 | |||
| 36 | L<FP::Interface> | ||
| 37 | |||
| 38 | This implements: L<FP::Abstract::Interface> | ||
| 39 | |||
| 40 | =head1 NOTE | ||
| 41 | |||
| 42 | This is alpha software! Read the status section in the package README | ||
| 43 | or on the L<website|http://functional-perl.org/>. | ||
| 44 | |||
| 45 | =cut | ||
| 46 | |||
| 47 | package FP::Interfaces; | ||
| 48 | 60 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 49 | 60 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 50 | 60 | ▶ | use warnings FATAL => 'uninitialized'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 51 | 60 | ▶ | use Exporter "import"; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 52 | |||
| 53 | 60 | our @EXPORT = qw(); | |
| 54 | 60 | our @EXPORT_OK = qw(); | |
| 55 | 60 | our %EXPORT_TAGS = (all => [@EXPORT, @EXPORT_OK]); | |
| 56 | |||
| 57 | 60 | ▶ | use FP::Interface; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 58 | |||
| 59 | # called fully qualified, i.e. FP::Interfaces::implemented (to avoid | ||
| 60 | # namespace pollution in classes) | ||
| 61 | 169 | ▶ | sub implemented { |
|
Subroutine
implemented: called CC=2 SCAR=6.9
Pod
undocumented
| |||
| 62 | 169 | my $caller = [caller]; | |
| 63 | 169 | for my $interface (@_) { | |
| 64 | 650 | FP::Interface::require_package($interface); | |
| 65 | 650 | FP::Interface::implemented_with_caller($caller, $interface) | |
| 66 | } | ||
| 67 | } | ||
| 68 | |||
| 69 | 60 | 1 | |