License | BSD-style (see the file LICENSE) |
---|---|
Maintainer | sjoerd@w3future.com |
Safe Haskell | Safe |
Language | Haskell2010 |
Synopsis
- traverse :: (Traversable t, Applicative f) => Square '[Star f] '[Star f] '[t] '[t]
- sequence :: (Traversable t, Applicative f) => Square '[] '[] '[f, t] '[t, f]
- mapAccumL :: Traversable t => Square '[Biff (->) ((,) s) ((,) s)] '[Biff (->) ((,) s) ((,) s)] '[t] '[t]
- mapAccumR :: Traversable t => Square '[Biff (->) ((,) s) ((,) s)] '[Biff (->) ((,) s) ((,) s)] '[t] '[t]
Documentation
traverse :: (Traversable t, Applicative f) => Square '[Star f] '[Star f] '[t] '[t] Source #
+--t--+ | v | f>-T->f | v | +--t--+
traverse
as a square.
Naturality law:
+-----t--+ +--t-----+ | v | | v | f>-@->T->g === f>-T->@->g | v | | v | +-----t--+ +--t-----+
Identity law:
+--t--+ +--t--+ | v | | | | | T | === | v | | v | | | | +--t--+ +--t--+
Composition law:
+--t--+ +--t--+ | v | | v | f>-T->f f>\|/>f | v | === | T | g>-T->g g>/|\>g | v | | v | +--t--+ +--t--+
traverse = (fromLeft ||| funId) === sequence === (funId ||| toRight)
sequence :: (Traversable t, Applicative f) => Square '[] '[] '[f, t] '[t, f] Source #
+-f-t---+ | v v | | \-@-\ | | v v | +---t-f-+
sequence = toRight ||| traverse ||| fromLeft