lens-5.3.3: Lenses, Folds and Traversals

Copyright | (C) 2012-16 Edward Kmett
License | BSD-style (see the file LICENSE)
Maintainer | Edward Kmett <ekmett@gmail.com>
Stability | provisional
Portability | MTPCs
Safe Haskell | Safe-Inferred
Language | Haskell2010

Data.Tree.Lens

Description

Synopsis

- root :: forall a f. Functor f => (a -> f a) -> Tree a -> f (Tree a)
- branches :: forall a f. Functor f => ([Tree a] -> f [Tree a]) -> Tree a -> f (Tree a)

# Documentation

root :: forall a f. Functor f => (a -> f a) -> Tree a -> f (Tree a) #

A `Lens` that focuses on the root of a `Tree`.

    >>> view root $ Node 42 []
    42

branches :: forall a f. Functor f => ([Tree a] -> f [Tree a]) -> Tree a -> f (Tree a) #

A `Lens` returning the direct descendants of the root of a `Tree`

    view branches ≡ subForest