>>> sequenceA [Just 1, Just 2, Just 3] Just [1,2,3]
>>> sequenceA [Right 1, Right 2, Right 3] Right [1,2,3]The next two example show Nothing and Just will short circuit the resulting structure if present in the input. For more context, check the Traversable instances for Either and Maybe.
>>> sequenceA [Just 1, Just 2, Just 3, Nothing] Nothing
>>> sequenceA [Right 1, Right 2, Right 3, Left 4] Left 4
>>> sequenceA_ [print "Hello", print "world", print "!"] "Hello" "world" "!"
>>> sequenceAOf both ([1,2],[3,4]) [(1,3),(1,4),(2,3),(2,4)]
sequenceA ≡ sequenceAOf traverse ≡ traverse id sequenceAOf l ≡ traverseOf l id ≡ l id
sequenceAOf :: Functor f => Iso s t (f b) b -> s -> f t sequenceAOf :: Functor f => Lens s t (f b) b -> s -> f t sequenceAOf :: Applicative f => Traversal s t (f b) b -> s -> f t
sequenceA_ ≡ sequenceAOf_ folded
>>> sequenceAOf_ both (putStrLn "hello",putStrLn "world") hello world
sequenceAOf_ :: Functor f => Getter s (f a) -> s -> f () sequenceAOf_ :: Applicative f => Fold s (f a) -> s -> f () sequenceAOf_ :: Functor f => Lens' s (f a) -> s -> f () sequenceAOf_ :: Functor f => Iso' s (f a) -> s -> f () sequenceAOf_ :: Applicative f => Traversal' s (f a) -> s -> f () sequenceAOf_ :: Applicative f => Prism' s (f a) -> s -> f ()
>>> sequenceA_ [putTextLn "foo", print True] foo True
sequenceAFoldable == sequenceA . Fold.toList