>>> 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
sequence :: Monad m => [m a] -> m [a] sequence :: Monad m => Stream (Of (m a)) m r -> Stream (Of a) m rThis obeys the rule
>>> input (sequence natural) "[1, 2, 3]" fromList [1,2,3]
sequence = mapM idReplace 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 1Concurrent (do not use with fromParallel on infinite streams)
>>> sequence = Stream.mapM idReplace 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