Skip to content

Commit

Permalink
Correct type graph of Seq
Browse files Browse the repository at this point in the history
  • Loading branch information
dumarchie committed Jan 24, 2020
1 parent 5ed062f commit 1b1fe10
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 28 deletions.
25 changes: 1 addition & 24 deletions doc/Type/Seq.pod6
Expand Up @@ -4,7 +4,7 @@
=SUBTITLE An iterable, potentially lazy sequence of values
class Seq is Cool does Iterable does PositionalBindFailover { }
class Seq is Cool does Iterable does Sequence { }
A C<Seq> represents anything that can produce a sequence of values. A
C<Seq> is born in a state where iterating it will consume the values.
Expand Down Expand Up @@ -101,29 +101,6 @@ Because an infinite sequence cannot be evaluated till the end, such a
sequence I<should> be declared lazy. Calling C<.elems> on a lazy C<Seq>
L<fails|/routine/fail> with L<X::Cannot::Lazy|/type/X::Cannot::Lazy>.
=head2 method eager
method eager(Seq:D: --> List:D)
Returns an eagerly evaluated L<List|/type/List> based on the invocant
sequence, and marks it as consumed.
If called on an already consumed sequence, throws an error of type
L<X::Seq::Consumed|/type/X::Seq::Consumed>.
my $s = lazy 1..5;
say $s.is-lazy; # OUTPUT: «True␤»
say $s.eager; # OUTPUT: «(1 2 3 4 5)␤»
say $s.eager;
CATCH {
when X::Seq::Consumed {
say 'Throws exception if already consumed';
}
}
# OUTPUT: «Throws exception if already consumed␤»
=head2 method from-loop
multi method from-loop(&body --> Seq:D)
Expand Down
21 changes: 20 additions & 1 deletion doc/Type/Sequence.pod6
Expand Up @@ -11,8 +11,27 @@ C<Seq>s into different types of objects, from positional to other.
=head1 Methods
=head2 method eager
TBD
method eager(::?CLASS:D: --> List:D)
Returns an eagerly evaluated L<List|/type/List> based on the invocant
sequence, and marks it as consumed.
If called on an already consumed sequence, throws an error of type
L<X::Seq::Consumed|/type/X::Seq::Consumed>.
my $s = lazy 1..5;
say $s.is-lazy; # OUTPUT: «True␤»
say $s.eager; # OUTPUT: «(1 2 3 4 5)␤»
say $s.eager;
CATCH {
when X::Seq::Consumed {
say 'Throws exception if already consumed';
}
}
# OUTPUT: «Throws exception if already consumed␤»
=end pod

Expand Down
6 changes: 3 additions & 3 deletions type-graph.txt
Expand Up @@ -234,12 +234,12 @@ class Thread
# Collections: Iteration
role Iterable
role Iterator
role PredictiveIterator does Iterator
role PredictiveIterator does Iterator
role PositionalBindFailover
class Seq is Cool does Iterable does PositionalBindFailover
role Sequence does PositionalBindFailover
class Seq is Cool does Iterable does Sequence
class RaceSeq does Iterable does Sequence
class HyperSeq does Iterable does Sequence
role Sequence

[Composite]
# Collections: Positional
Expand Down

0 comments on commit 1b1fe10

Please sign in to comment.