-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Tutorial for the lens library -- -- This is a basic tutorial that you can use to get started with the -- lens library. This tutorial covers: -- -- @package lens-tutorial @version 1.0.5 -- | This lens tutorial targets Haskell beginners and assumes only -- basic familiarity with Haskell. By the end of this tutorial you -- should: -- -- -- -- If you would like to follow along with these examples, just import -- this module: -- --
--   $ ghci
--   >>> import Control.Lens.Tutorial
--   
module Control.Lens.Tutorial data Atom Atom :: String -> Point -> Atom [_element] :: Atom -> String [_point] :: Atom -> Point element :: Lens' Atom String point :: Lens' Atom Point data Point Point :: Double -> Double -> Point [_x] :: Point -> Double [_y] :: Point -> Double x :: Lens' Point Double y :: Lens' Point Double data Molecule Molecule :: [Atom] -> Molecule [_atoms] :: Molecule -> [Atom] atoms :: Iso' Molecule [Atom] data Pair a Pair :: a -> a -> Pair a -- | Map each element of a structure to an action, evaluate these actions -- from left to right, and collect the results. For a version that -- ignores the results see traverse_. -- --

Examples

-- -- Basic usage: -- -- In the first two examples we show each evaluated action mapping to the -- output structure. -- --
--   >>> traverse Just [1,2,3,4]
--   Just [1,2,3,4]
--   
-- --
--   >>> traverse id [Right 1, Right 2, Right 3, Right 4]
--   Right [1,2,3,4]
--   
-- -- In the next examples, we show that Nothing and Left -- values short circuit the created structure. -- --
--   >>> traverse (const Nothing) [1,2,3,4]
--   Nothing
--   
-- --
--   >>> traverse (\x -> if odd x then Just x else Nothing)  [1,2,3,4]
--   Nothing
--   
-- --
--   >>> traverse id [Right 1, Right 2, Right 3, Right 4, Left 0]
--   Left 0
--   
traverse :: (Traversable t, Applicative f) => (a -> f b) -> t a -> f (t b) instance GHC.Show.Show Control.Lens.Tutorial.Point instance GHC.Show.Show Control.Lens.Tutorial.Atom instance GHC.Show.Show Control.Lens.Tutorial.Molecule instance Data.Traversable.Traversable Control.Lens.Tutorial.Pair instance Data.Foldable.Foldable Control.Lens.Tutorial.Pair instance GHC.Base.Functor Control.Lens.Tutorial.Pair