Data::Focus::Applicative - applicative functor spec for Data::Focus
This interface is experimental for now. You should not use them directly.
This class specifies the common interface for all applicative functors used in Data::Focus distribution.
All applicative functors must inherit Data::Focus::Applicative, and implement the following methods.
Build the $f_result with $builder and @f_parts.
$f_result
$builder
@f_parts
@f_parts are zero or more Data::Focus::Applicative objects. They must be instances of the $class. build() method is the only interface where you can access raw data wrapped inside @f_parts.
$class
build()
$builder is a code-ref, which may be called zero or more times
$result = $builder->(@parts)
where @parts are the data inside @f_parts applicative functors.
@parts
Return value $f_result is an object of the $class. It wraps the $result.
$result
Wraps $result with an wrapper object of $class. This is equivalent to $class->build(sub { $result }).
$class->build(sub { $result })
Internal use only.
Create the finest $part_mapper for Data::Focus::Lens.
$part_mapper
$updater is a code-ref. This code-ref is supposed to modify the finest part and return the result. Subclasses may or may not use $updater to create $part_mapper.
$updater
In pseudo-Haskell, build() method is equivalent to
build :: Applicative f => (b -> b -> ... -> t) -> [f b] -> f t build builder f_parts = case f_parts of [] -> pure builder -- (builder :: t) in this case (p:ps) -> builder <$> p <*> (ps !! 0) <*> (ps !! 1) ...
I think this is the only pattern where applicative functors are used in Lens implementations.
The signature of create_part_mapper() method is
create_part_mapper()
create_part_mapper :: Applicative f => (a -> b) -> (a -> f b)
Toshio Ito, <toshioito at cpan.org>
<toshioito at cpan.org>
To install Data::Focus, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Data::Focus
CPAN shell
perl -MCPAN -e shell install Data::Focus
For more information on module installation, please visit the detailed CPAN module installation guide.