sequence -package:vector-sized

Evaluate each monadic action in the structure from left to right, and collect the results. For a version that ignores the results see sequence_.

Examples

Basic usage: The first two examples are instances where the input and and output of sequence are isomorphic.
>>> sequence $ Right [1,2,3,4]
[Right 1,Right 2,Right 3,Right 4]
>>> sequence $ [Right 1,Right 2,Right 3,Right 4]
Right [1,2,3,4]
The following examples demonstrate short circuit behavior for sequence.
>>> sequence $ Left [1,2,3,4]
Left [1,2,3,4]
>>> sequence $ [Left 0, Right 1,Right 2,Right 3,Right 4]
Left 0
Evaluate each action in the sequence from left to right, and collect the results.
Run a Pipe repeatedly, and output its result value downstream. Stops when no more input is available from upstream. Since 0.5.0
Convert a stream of actions to a stream of values
Like the sequence but streaming. The result type is a stream of a's, but is not accumulated; the effects of the elements of the original stream are interleaved in the resulting stream. Compare:
sequence :: Monad m =>       [m a]           -> m [a]
sequence :: Monad m => Stream (Of (m a)) m r -> Stream (Of a) m r
This obeys the rule
Evaluate each monadic action in the structure from left to right, and collect the results. For a version that ignores the results see sequence_.
Evaluate each action and collect the results
Evaluate each action and collect the results
Decode a Seq.
>>> input (sequence natural) "[1, 2, 3]"
fromList [1,2,3]
Evaluate each action in the sequence and collect the results
sequence = mapM id
Replace the elements of a stream of monadic actions with the outputs of those actions.
>>> drain $ Stream.sequence $ Stream.fromList [putStr "a", putStr "b", putStrLn "c"]
abc

>>> :{
drain $ Stream.replicateM 3 (return $ threadDelay 1000000 >> print 1)
& (fromSerial . Stream.sequence)
:}
1
1
1

>>> :{
drain $ Stream.replicateM 3 (return $ threadDelay 1000000 >> print 1)
& (fromAsync . Stream.sequence)
:}
1
1
1
Concurrent (do not use with fromParallel on infinite streams)
Evaluate each action in the structure from left to right and collect the results. For a version that ignores the results see sequence_.
Like sequence, but executing the actions in parallel.
Applicative sequencing over a record.
Applicative sequencing over a variant
Deprecated: Use "rmapM id" instead
>>> sequence = Stream.mapM id
Replace the elements of a stream of monadic actions with the outputs of those actions.
>>> s = Stream.fromList [putStr "a", putStr "b", putStrLn "c"]

>>> Stream.fold Fold.drain $ Stream.sequence s
abc
sequence f p collects sequential parses of parsers in a serial stream p using the fold f. Fails if the input ends or any of the parsers fail. Pre-release
Evaluate each monadic action in the list sequentially, and collect the results.
Evaluate each actions of the given collections, from left to right, and collect the results. For a version that ignores the results, see sequence_
lock-time using sequence numbers (BIP-68)