hexpat-lens-0.1.7: Lenses for Hexpat.

Copyright(c) 2013 Joseph Abrahamson
LicenseMIT
Maintainerme@jspha.com
Stabilityexperimental
Portabilitynon-portable
Safe HaskellNone
LanguageHaskell2010

Text.XML.Expat.Lens.Generic

Contents

Description

A Hexpat lens module for generic tags.

Lenses provide power to do very concise XML tree diving. This module provides a less general interface to the Hexpat datatypes via lenses.

Synopsis

Basic inspection

name :: Traversal' (NodeG f tag text) tag Source #

Traverses the name of an Element. This is as an Affine, or 0-or-1 target, Traversal. In regex terms, you can think of it like the ? suffix modifier.

attributes :: Traversal' (NodeG f tag text) (Attributes tag text) Source #

Traverses to the list of attributes of an Element. This is as an Affine, or 0-or-1 target, Traversal. In regex terms, you can think of it like the ? suffix modifier.

text :: Prism' (NodeG f tag text) text Source #

Prismatic access to the text of a Text node. This is more powerful than name, children, and attributes since it can be Reviewed.

Recursive inspection

children :: Traversal' (NodeG f tag text) (f (NodeG f tag text)) Source #

Traverses the children of an Element. This is as an Affine, or 0-or-1 target, Traversal. In regex terms, you can think of it like the ? suffix modifier.

allNodes :: Traversable c => NodeG c tag text -> [NodeG c tag text] Source #

Produces a list of all UNodes in a XML tree. Synonym for universe.

(./) :: Plated i => Traversal' s i -> Traversal' i a -> Traversal' s a infixr 9 Source #

Glue two Traversals together as relations. This is much like XPath's *slash*.

Filters

named :: (Eq a, Applicative f, Choice p) => a -> Optic' p f (NodeG f1 a text) (NodeG f1 a text) Source #

Traverses Elements which have a particular name.

parameterized :: (Eq (IxValue a), Applicative f, Choice p, Ixed a) => Index a -> IxValue a -> Optic' p f a a Source #

parameterized k v traverses Elements which match the value v at the key k in their attributes.

Orphan instances

Eq tag => Ixed (NodeG c tag text) Source # 

Methods

ix :: Index (NodeG c tag text) -> Traversal' (NodeG c tag text) (IxValue (NodeG c tag text)) #

Eq tag => At (NodeG f tag text) Source #

This forms a valid At instance under the assumption that there are no repeated keys in the Attributes list. Since hexpat won't parse invalid XML this holds after parsing, so this At instance is valid so long as the invariants aren't subverted in some other way, such as by modify the Attributes list directly via the attributes Traversal.

Methods

at :: Index (NodeG f tag text) -> Lens' (NodeG f tag text) (Maybe (IxValue (NodeG f tag text))) #

Traversable f => Plated (NodeG f tag text) Source # 

Methods

plate :: Traversal' (NodeG f tag text) (NodeG f tag text) #