Idris2Doc : FS.Pull

FS.Pull

(source)
General operations on `Pull`s
and `Stream`s: Splits, scans, filters, and maps

It is suggested to import this qualified `import FS.Pull as P` or
via the catch-all module `FS` and use qualified names such
as `P.filter` for those functions that overlap with the ones
from `FS.Chunk`.

Reexports

importpublic FS.Core

Definitions

dataUnfoldRes : Type->Type->Type->Type
Totality: total
Visibility: public export
Constructors:
More : o->s->UnfoldResrso
Done : r->UnfoldResrso
Last : r->o->UnfoldResrso
emits : Listo->Streamfeso
  Emits a list of chunks.

Totality: total
Visibility: export
emitList : Listo->Streamfes (Listo)
  Emits a list of values as a single chunk.

Totality: total
Visibility: export
emitMaybe : Maybeo->Streamfeso
  Emits a single optional value.

Totality: total
Visibility: export
emitSnoc : SnocListo->Maybeo->Streamfes (Listo)
  Utility to emit a single list chunk from a snoc list.

Totality: total
Visibility: export
eval : feso->Streamfeso
  Emits a single chunk of output generated from an effectful
computation.

Totality: total
Visibility: export
unfold : s-> (s->UnfoldResrso) ->Pullfoesr
  Like `unfold` but emits values in larger chunks.

This allows us to potentially emit a bunch of values right before
we are done.

This overlaps with function `FS.Chunk.unfold`, so it is typically
used qualified: `P.unfold`.

Totality: total
Visibility: export
unfoldEval : s-> (s->fes (UnfoldResrso)) ->Pullfoesr
  Like `unfold` but produces values via an effectful computation
until a `Done` or `Last` is returned.

Totality: total
Visibility: export
unfoldEvalMaybe : fes (Maybeo) ->Streamfeso
  Produces values via an effectful computation
until a `Nothing` is returned.

Totality: total
Visibility: export
fill : o->Pullfoes ()
  Infinitely produces chunks of values of the given size

Totality: total
Visibility: export
iterate : o-> (o->o) ->Pullfoes ()
  An infinite stream of values of type `o` where
the next value is built from the previous one by
applying the given function.

Totality: total
Visibility: export
replicate : Nat->o->Streamfeso
  Produces the given chunk of value `n` times.

Totality: total
Visibility: export
repeat : Streamfeso->Pullfoes ()
  Infinitely cycles through the given `Pull`

Totality: total
Visibility: export
consMaybe : Maybeo->Pullfoesr->Pullfoesr
  Prepends the given optional output to a pull.

Totality: total
Visibility: export
cycle : (as : Lista) -> {auto0_ : NonEmptyas} ->Streamfesa
  Infinitely cycles through the values in the given
non-empty list.

Totality: total
Visibility: export
dataBreakInstruction : Type
Totality: total
Visibility: public export
Constructors:
TakeHit : BreakInstruction
  Take the first succeeding value as part of the emitted prefix
PostHit : BreakInstruction
  Keep the succeeding value as part of the postfix.
DropHit : BreakInstruction
  Discard the succeeding value
peek : Pullfoesr->Pullfqes (Eitherr (o, Pullfoesr))
  Like `uncons` but does not consume the chunk

Totality: total
Visibility: export
peekRes : Pullfoesr->Pullfqes (Eitherr (Pullfoesr))
  Like `peeks` but only checks if the pull has been exhausted or not.

Totality: total
Visibility: export
drain : Pullfoesr->Pullfqesr
  Empties a stream silently dropping all output.

Totality: total
Visibility: export
splitAt : Nat->Pullfoesr->Pullfoes (Pullfoesr)
  Emits the first `n` values of a `Pull`, returning the remainder.

In case the remaining pull is exhausted, with will wrap the
final result in a `Left`, otherwise, the (non-empty) remainder will be
wrapped in a right.

Totality: total
Visibility: export
take : Nat->Pullfoesr->Streamfeso
  Emits only the first `n` values of a `Stream`.

Totality: total
Visibility: export
limit : Hasees=> Lazy e->Nat->Pullfoesr->Pullfoesr
  Like `take` but limits the number of emitted values.

This fails with the given error in case the limit is exceeded.

Note: This tries to read past the end of a pull by invoking `peekRes`.
This is not suitable for limitting the input from a stream that
blocks once it is exhausted.

Totality: total
Visibility: export
drop : Nat->Pullfoesr->Pullfoesr
  Discards the first `n` values of a `Stream`, returning the
remainder.

Totality: total
Visibility: export
head : Pullfoesr->Streamfeso
  Only keeps the first element of the input.

Totality: total
Visibility: export
tail : Pullfoesr->Pullfoesr
  Drops the first element of the input.

Totality: total
Visibility: export
dataBreakRes : Type->Type
  Result of splitting a value into two parts. This is used to
split up streams of data along logical boundaries.

Totality: total
Visibility: public export
Constructors:
Broken : Maybec->Maybec->BreakResc
  The value was broken and we got a (possibly empty) pre- and postfix.
Keep : c->BreakResc
  The value could not be broken.
breakPull : (r->Pullfoesr) -> (o->BreakReso) ->Pullfoesr->Pullfoes (Pullfoesr)
  Uses the given breaking function to break the pull into
a prefix of emitted chunks and a suffix that is returned as
the result.

Totality: total
Visibility: export
breakFull : (r->Pullfoesr) ->BreakInstruction-> (o->Bool) ->Pullfoesr->Pullfoes (Pullfoesr)
  Breaks a pull as soon as the given predicate returns `True`.

The `BreakInstruction` dictates, if the value, for which the
predicate held, should be emitted as part of the prefix or the
suffix, or if it should be discarded.

Totality: total
Visibility: export
forceBreakFull : Hasees=> Lazy e->BreakInstruction-> (o->Bool) ->Pullfoesr->Pullfoes (Pullfoesr)
  Like `breakFull` but fails with the given execption if no
breaking point was found.

Totality: total
Visibility: export
takeUntil : BreakInstruction-> (o->Bool) ->Pullfoesr->Streamfeso
  Emits values until the given predicate returns `True`.

The `BreakInstruction` dictates, if the value, for which the
predicate held, should be emitted as part of the prefix or not.

Totality: total
Visibility: export
takeWhile : (o->Bool) ->Pullfoesr->Streamfeso
  Emits values until the given predicate returns `False`,
returning the remainder of the `Pull`.

Totality: total
Visibility: export
takeThrough : (o->Bool) ->Pullfoesr->Streamfeso
  Like `takeWhile` but also includes the first failure.

Totality: total
Visibility: export
takeWhileJust : Pullf (Maybeo) esr->Streamfeso
  Emits values until the given pull emits a `Nothing`.

Totality: total
Visibility: export
dropUntil : BreakInstruction-> (o->Bool) ->Pullfoesr->Pullfoesr
  Discards values until the given predicate returns `True`.

The `BreakInstruction` dictates, if the value, for which the
predicate held, should be emitted as part of the remainder or not.

Totality: total
Visibility: export
dropWhile : (o->Bool) ->Pullfoesr->Pullfoesr
  Drops values from a stream while the given predicate returns `True`,
returning the remainder of the stream.

Totality: total
Visibility: export
dropThrough : (o->Bool) ->Pullfoesr->Pullfoesr
  Like `dropWhile` but also drops the first value where
the predicate returns `False`.

Totality: total
Visibility: export
mapMaybe : (o->Maybep) ->Pullfoesr->Pullfpesr
  Maps chunks of output via a partial function.

Totality: total
Visibility: export
catMaybes : Pullf (Maybeo) esr->Pullfoesr
  Emits a values wrapped in a `Just` from the initial stream.

Totality: total
Visibility: export
mapRight : (o->Eitherep) ->Pullfoesr->Pullfpesr
  Emits the values, for which the given function returns a `Right`.

Totality: total
Visibility: export
catRights : Pullf (Eithereo) esr->Pullfoesr
  Emits the values wrapped `Rights`.

Totality: total
Visibility: export
mapLeft : (o->Eitherep) ->Pullfoesr->Pullfeesr
  Emits the values, for which the given function returns a `Right`.

Totality: total
Visibility: export
catLefts : Pullf (Eithereo) esr->Pullfeesr
  Emits the values wrapped `Rights`.

Totality: total
Visibility: export
mapOutput : (o->p) ->Pullfoesr->Pullfpesr
  Chunk-wise maps the emit of a `Pull`

Totality: total
Visibility: export
evalMap : (o->fesp) ->Pullfoesr->Pullfpesr
  Chunk-wise effectful mapping of the emit of a `Pull`

Totality: total
Visibility: export
evalMapMaybe : (o->fes (Maybep)) ->Pullfoesr->Pullfpesr
  Chunk-wise effectful mapping of the emit of a `Pull`

Totality: total
Visibility: export
filter : (o->Bool) ->Pullfoesr->Pullfoesr
  Chunk-wise filters the emit of a `Pull` emitting only the
values that fulfill the given predicate

Totality: total
Visibility: export
filterNot : (o->Bool) ->Pullfoesr->Pullfoesr
  Convenience alias for `filterC (not . pred)`.

Totality: total
Visibility: export
endWithNothing : Pullfoesr->Pullf (Maybeo) esr
  Wraps the values emitted by this stream in a `Just` and
marks its end with a `Nothing`.

Totality: total
Visibility: export
pairLastOr : Lazy o->Pullfoesr->Pullfpes (o, r)
  Returns the first output of this stream and pairs it with the
result.

The remainder of the pull is drained and run to completion.

Totality: total
Visibility: export
lastOr : Lazy o->Streamfeso->Pullfpeso
  Like `pairLastOr` but operates on a stream and therefore only returns
the last output.

Totality: total
Visibility: export
pairLastOrErr : Hasees=> Lazy e->Pullfoesr->Pullfpes (o, r)
  Like `firstOr` but fails with the given error in case no
value is emitted.

Totality: total
Visibility: export
lastOrErr : Hasees=> Lazy e->Streamfeso->Pullfpeso
  Like `pairLastOrErr` but operates on a stream and therefore only returns
the last output.

Totality: total
Visibility: export
fold : (p->o->p) ->p->Pullfoesr->Pullfpesr
  Folds the emit of a pull using an initial value and binary operator.

The accumulated result is emitted as a single value.

Totality: total
Visibility: export
foldPair : (p->o->p) ->p->Pullfoesr->Pullfqes (p, r)
  Like `fold` but instead of emitting the result as a single
value of output, it is paired with the `Pull`s result.

Totality: total
Visibility: export
foldPairE : Hasees=> (p->o->Eitherep) ->p->Pullfoesr->Pullfqes (p, r)
  Like `foldPair` but with a function that can fail.

Totality: total
Visibility: export
foldGet : (p->o->p) ->p->Streamfeso->Pullfqesp
  Convenience version of `foldPair` for working on streams.

Totality: total
Visibility: export
fold1 : (o->o->o) ->Pullfoesr->Pullfoesr
  Like `foldC` but will not emit a value in case of an empty pull.

Totality: total
Visibility: export
all : (o->Bool) ->Pullfoesr->StreamfesBool
  Emits `True` if all emitted values of the given stream fulfill
the given predicate

Totality: total
Visibility: export
any : (o->Bool) ->Pullfoesr->StreamfesBool
  Returns `True` if any of the emitted values of the given stream fulfills
the given predicate

Totality: total
Visibility: export
sum : Numo=>Pullfoesr->Pullfoesr
  Sums up the emitted chunks.

Totality: total
Visibility: export
count : Pullfoesr->PullfNatesr
  Counts the number of emitted chunks.

Totality: total
Visibility: export
maximum : Ordo=>Pullfoesr->Pullfoesr
  Emits the largest output encountered.

Totality: total
Visibility: export
minimum : Ordo=>Pullfoesr->Pullfoesr
  Emits the smallest output encountered.

Totality: total
Visibility: export
mappend : Semigroupo=>Pullfoesr->Pullfoesr
  Emits the smallest output encountered.

Totality: total
Visibility: export
foldMap : Monoidm=> (o->m) ->Pullfoesr->Pullfmesr
  Accumulates the emitted values over a monoid.

Note: This corresponds to a left fold, so it will
run in quadratic time for monoids that are
naturally accumulated from the right (such as List)

Totality: total
Visibility: export
evalFold : (p->o->fesp) ->p->Pullfoesr->Pullfpesr
  Folds the emit of a pull using an initial value and binary operator.

The accumulated result is emitted as a single value.

Totality: total
Visibility: export
evalFoldPair : (p->o->fesp) ->p->Pullfoesr->Pullfqes (p, r)
  Like `fold` but instead of emitting the result as a single
value of output, it is paired with the `Pull`s result.

Totality: total
Visibility: export
evalFoldGet : (p->o->fesp) ->p->Streamfeso->Pullfqesp
  Convenience version of `evalFoldPair` for working on streams.

Totality: total
Visibility: export
scan : s-> (s->o-> (p, s)) ->Pullfoesr->Pullfpesr
  Runs a stateful computation across all chunks of data.

Totality: total
Visibility: export
distinctBy : (o->o->Bool) ->Pullfoesr->Pullfoesr
  Emits values of the original pull, but emits consecutive
values for which `f` returns `True` only once.

Note: For this to work correctly, `f` must be an equivalence relation.
This function makes no guarantees about the order in which arguments
are passed to `f`, so `f` must be symmetric. It also makes
no guarantees about which emitted value is being kept in its
internal state, so `f` must be transitive.

Totality: total
Visibility: export
distinct : Eqo=>Pullfoesr->Pullfoesr
  Emits values of the original pull, but emits consecutive
identical values only once.

Totality: total
Visibility: export
scanMaybe : s-> (s->Maybe (o-> (p, s))) ->Pullfoesr->Pullfpess
  General stateful conversion of a `Pull`s emit.

Aborts as soon as the given accumulator function returns `Nothing`

Totality: total
Visibility: export
scanFull : s-> (s->o-> (Maybep, s)) -> (s->Maybep) ->Pullfoesr->Pullfpesr
  Like `scan` but will possibly also emit the final state.

Totality: total
Visibility: export
zipWithScan : p-> (p->o->p) ->Pullfoesr->Pullf (o, p) esr
  Zips the input with a running total, up to but
not including the current element.

Totality: total
Visibility: export
zipWithScan1 : p-> (p->o->p) ->Pullfoesr->Pullf (o, p) esr
  Like `zipWithScan` but the running total is including the current element.

Totality: total
Visibility: export
zipWithIndex : Pullfoesr->Pullf (o, Nat) esr
  Pairs each element in the stream with its 0-based index.

Totality: total
Visibility: export
zipWithCount : Pullfoesr->Pullf (o, Nat) esr
  Pairs each element in the stream with its 1-based count.

Totality: total
Visibility: export
scans : p-> (p->o->p) ->Pullfoesr->Pullfpesr
  Accumulates the input value using the given function.

The emitted result will include the input up to but
not including the current value.

Totality: total
Visibility: export
scans1 : p-> (p->o->p) ->Pullfoesr->Pullfpesr
  Like `scans` but the running total is including the current element.

Emits the initial value as its first output.

Totality: total
Visibility: export
scanFrom : o->Pullf (o->o) esr->Pullfoesr
  Like `scans` but specialized to a pull of unary functions.

Totality: total
Visibility: export
scanFrom1 : o->Pullf (o->o) esr->Pullfoesr
  Like `scans1` but specialized to a pull of unary functions.

Totality: total
Visibility: export
runningCount : Pullfoesr->PullfNatesr
  Emits the count of each element.

Totality: total
Visibility: export
evalScan : s-> (s->o->fes (p, s)) ->Pullfoesr->Pullfpesr
  Like `scan` but with an effectful computation.

Totality: total
Visibility: export
evalScans : Functor (fes) =>p-> (p->o->fesp) ->Pullfoesr->Pullfpesr
  Accumulates the input value using the given function.

The emitted result will include the input up to but
not including the current value.

Totality: total
Visibility: export
evalScans1 : Functor (fes) =>p-> (p->o->fesp) ->Pullfoesr->Pullfpesr
  Like `scans` but the running total is including the current element.

Totality: total
Visibility: export
evalScanFrom : Functor (fes) =>o->Pullf (o->feso) esr->Pullfoesr
  Like `evalScans` but specialized to a pull of unary effectful functions.

Totality: total
Visibility: export
evalScanFrom1 : Functor (fes) =>o->Pullf (o->feso) esr->Pullfoesr
  Like `evalScans1` but specialized to a pull of unary effectful functions.

Totality: total
Visibility: export
foreach : (o->fes ()) ->Pullfoesr->Pullfqesr
  Performs the given action on each emitted chunk of values, thus draining
the stream, consuming all its output.

For acting on output without actually draining the stream, see
`observe` and `observe1`.

Totality: total
Visibility: export
foreach' : fes () ->Pullfoesr->Pullfqesr
  Utility alias for `foreach . const`.

Totality: total
Visibility: export
observe : (o->fes ()) ->Pullfoesr->Pullfoesr
  Performs the given action on every chunk of values of the stream without
otherwise affecting the emitted values.

Totality: total
Visibility: export
observe' : fes () ->Pullfoesr->Pullfoesr
  Utility alias for `observe . const`.

Totality: total
Visibility: export
flatMap : Pullfoesr-> (o->Streamfesp) ->Pullfpesr
  Converts every chunk of output to a new stream,
concatenating the resulting streams before emitting the final
result.

Totality: total
Visibility: export
bind : (o->Pullfpes ()) ->Pullfoesr->Pullfpesr
  Flipped version of `flatMapC`

Totality: total
Visibility: export
attemptOutput : Pullfoes () ->Pullf (Resulteso) fs ()
Totality: total
Visibility: export
stepLeg : Streamfeso->Pullfpes (Maybe (StepLegfeso))
  This is an internal utility to run the remainder of a stream
in the correct scope.

Totality: total
Visibility: export
step : StepLegfeso->Pullfpes (Maybe (StepLegfeso))
  Runs a `StepLeg` in its scope, returning then next `StepLeg`.

Totality: total
Visibility: export
0ZipWithLeft : (ListType->Type->Type) ->ListType->Type->Type->Type
  Type alias for a function that converts a stream plus
a prefix to a stream emitting different values.

Totality: total
Visibility: public export
zipAllWith : o1->o2-> (o1->o2->o3) ->Streamfeso1->Streamfeso2->Streamfeso3
  Determinsitically zips elements with the specified function, terminating
when the ends of both branches are reached naturally, padding the left
branch with `pad1` and padding the right branch with `pad2` as necessary.

Totality: total
Visibility: export
zipAll : o1->o2->Streamfeso1->Streamfeso2->Streamfes (o1, o2)
  `zipAllWith` specialized to returning a pair of values

Totality: total
Visibility: export
zipWith : (o1->o2->o3) ->Streamfeso1->Streamfeso2->Streamfeso3
  Deterministically zips elements, terminating when the end
of either branch is reached naturally.

Totality: total
Visibility: export
zip : Streamfeso1->Streamfeso2->Streamfes (o1, o2)
  `zipAll` specialized to returning a pair of values

Totality: total
Visibility: export
Fixity Declaration: infixr operator, level 6
zipRight : Streamfeso1->Streamfeso2->Streamfeso2
Totality: total
Visibility: export
zipLeft : Streamfeso1->Streamfeso2->Streamfeso1
Totality: total
Visibility: export
hzip : All (Streamfes) ts->Streamfes (HListts)
  Zips the values in a heterogeneous list of streams.

Totality: total
Visibility: export
0HZipFun : ListType->Type->Type
Totality: total
Visibility: public export
happly : HZipFuntsr->HListts->r
Totality: total
Visibility: export
hzipWith : HZipFuntsr->All (Streamfes) ts->Streamfesr
  Zips the given streams applying the resulting heterogeneous
lists of values to the given function.

Totality: total
Visibility: export