本間 雅洋 (Masahiro Honma) > Data-Monad-0.04 > Data::Monad::List

Download:
Data-Monad-0.04.tar.gz

Dependencies

Annotate this POD

Website

View/Report Bugs
Source   Latest Release: Data-Monad-0.07

NAME ^

Data::Monad::List - The List monad.

SYNOPSIS ^

  use Data::Monad::List;
  my $m = scalar_list(10, 20);
  $m = $m->flat_map(sub {
      my $v = shift;
      scalar_list($v + 1, $v + 2);
  });
  my @result = $m->scalars; # (11, 12, 21, 22)

DESCRIPTION ^

Data::Monad::List represents non-deterministic values.

This module is marked EXPERIMENTAL. API could be changed without any notice.

METHODS ^

$list = scalar_list(@single_values)

Is the same as following lines.

  $list = Data::Monad::List->new([$single_values[0]], [$single_values[1]], ...)
$list = list_unit(@values)
$list = list_zero()
$f = list_flat_map_multi(\&f, $list1, $list2, ...)
$f = list_map_multi(\&f, $list1, $list2, ...)
$list = list_sequence($list1, $list2, ...)

These are shorthand of methods which has the same name.

$list = Data::Monad::List->new(\@values1, \@values2, ...)

The constructor of this class.

zero

Overrides methods of Data::Monad::Base::MonadZero.

unit
flat_map

Overrides methods of Data::Monad::Base::Monad.

@values = $list->values

Retrieves list of values from $list

@single_values = $list->scalars

Retrieves values which was set by the scalar_list method.

AUTHOR ^

hiratara <hiratara {at} cpan.org>

SEE ALSO ^

Data::Monad::Base::Monad

LICENSE ^

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

syntax highlighting: