-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | CSS selectors for HXT
--   
--   This package makes it possible to easily traverse (X)HTML/XML
--   documents using CSS selectors. It supports all CSS level 3 selectors
--   except the ones that do not make sense outside a web browser (e.g.
--   such as <tt>:hover</tt> or <tt>::first-letter</tt>). Also, there is no
--   support for namespaced selectors.
@package hxt-css
@version 0.1.0.3


-- | Data types for the abstract syntax tree of CSS selectors. We (mostly)
--   follow the naming conventions of the CSS Level 3 specification
--   document (<a>http://www.w3.org/TR/css3-selectors/</a>). The type
--   hierarchy tries to strike a balance between correctness and
--   complexity. As a result, it is possible to construct values that
--   correspond to invalid selectors. For example,
--   
--   <pre>
--   <a>Negation</a> (<a>Negation</a> <a>UniversalSelector</a>)
--   </pre>
--   
--   is not valid according to the spec, as double negation is not allowed.
--   Note that <a>parseCSS</a> never produces invalid selectors.
module Text.XML.HXT.CSS.TypeDefs

-- | The top-level selector type.
newtype SelectorsGroup

-- | <pre>
--   E, F
--   </pre>
SelectorsGroup :: [Selector] -> SelectorsGroup
data Selector

-- | <pre>
--   E
--   </pre>
Selector :: SimpleSelectorSeq -> Selector

-- | <pre>
--   E F
--   </pre>
Descendant :: SimpleSelectorSeq -> Selector -> Selector

-- | <pre>
--   E &gt; F
--   </pre>
Child :: SimpleSelectorSeq -> Selector -> Selector

-- | <pre>
--   E + F
--   </pre>
AdjSibling :: SimpleSelectorSeq -> Selector -> Selector

-- | <pre>
--   E ~ F
--   </pre>
FolSibling :: SimpleSelectorSeq -> Selector -> Selector
newtype SimpleSelectorSeq

-- | <pre>
--   tag#id.class:pseudo
--   </pre>
SimpleSelectorSeq :: [SimpleSelector] -> SimpleSelectorSeq
data SimpleSelector

-- | <pre>
--   *
--   </pre>
UniversalSelector :: SimpleSelector

-- | <pre>
--   tag
--   </pre>
TypeSelector :: String -> SimpleSelector

-- | <pre>
--   #id
--   </pre>
IdSelector :: String -> SimpleSelector

-- | <pre>
--   .class
--   </pre>
ClassSelector :: String -> SimpleSelector

-- | <pre>
--   [..]
--   </pre>
AttrSelector :: String -> AttrTest -> SimpleSelector

-- | <pre>
--   :pseudo
--   </pre>
Pseudo :: PseudoClass -> SimpleSelector

-- | <pre>
--   :pseudo(2)
--   </pre>
PseudoNth :: PseudoNthClass -> SimpleSelector

-- | <pre>
--   :not(..)
--   </pre>
Negation :: SimpleSelector -> SimpleSelector
data AttrTest

-- | <pre>
--   [attr]
--   </pre>
AttrExists :: AttrTest

-- | <pre>
--   [attr=var]
--   </pre>
AttrEq :: String -> AttrTest

-- | <pre>
--   [attr~=var]
--   </pre>
AttrContainsSp :: String -> AttrTest

-- | <pre>
--   [attr|=var]
--   </pre>
AttrBeginHy :: String -> AttrTest

-- | <pre>
--   [attr^=var]
--   </pre>
AttrPrefix :: String -> AttrTest

-- | <pre>
--   [attr$=var]
--   </pre>
AttrSuffix :: String -> AttrTest

-- | <pre>
--   [attr*=var]
--   </pre>
AttrSubstr :: String -> AttrTest

-- | Pseudo classes.
data PseudoClass

-- | <pre>
--   :first-child
--   </pre>
PseudoFirstChild :: PseudoClass

-- | <pre>
--   :last-child
--   </pre>
PseudoLastChild :: PseudoClass

-- | <pre>
--   :only-child
--   </pre>
PseudoOnlyChild :: PseudoClass

-- | <pre>
--   :first-of-type
--   </pre>
PseudoFirstOfType :: PseudoClass

-- | <pre>
--   :last-of-type
--   </pre>
PseudoLastOfType :: PseudoClass

-- | <pre>
--   :only-of-type
--   </pre>
PseudoOnlyOfType :: PseudoClass

-- | <pre>
--   :empty
--   </pre>
PseudoEmpty :: PseudoClass

-- | <pre>
--   :root
--   </pre>
PseudoRoot :: PseudoClass

-- | Pseudo classes that expect a argument of type <a>Nth</a>.
data PseudoNthClass

-- | <pre>
--   :nth-child(..)
--   </pre>
PseudoNthChild :: Nth -> PseudoNthClass

-- | <pre>
--   :nth-last-child(..)
--   </pre>
PseudoNthLastChild :: Nth -> PseudoNthClass

-- | <pre>
--   :nth-of-type(..)
--   </pre>
PseudoNthOfType :: Nth -> PseudoNthClass

-- | <pre>
--   :nth-last-of-type(..)
--   </pre>
PseudoNthLastOfType :: Nth -> PseudoNthClass

-- | Type of the argument of the <tt>:nth-child</tt>
--   (<a>PseudoNthClass</a>) family of pseudo classes. <tt><a>Nth</a> a
--   b</tt> matches with all integers that can be written in the form
--   <tt>an+b</tt> for some nonnegative integer <tt>n</tt>.
data Nth

-- | <pre>
--   an+b
--   </pre>
Nth :: Int -> Int -> Nth

-- | <pre>
--   odd
--   </pre>
Odd :: Nth

-- | <pre>
--   even
--   </pre>
Even :: Nth

-- | Find a <a>PseudoClass</a> given its name (without the colon).
findPseudoClass :: String -> Maybe PseudoClass

-- | Find a <a>PseudoNthClass</a> given its name (without the colon).
findPseudoNthClass :: String -> Maybe (Nth -> PseudoNthClass)

-- | Check whether an integer satisfies a "Diophantine" constraint given in
--   form of a value of type <a>Nth</a>.
testNth :: Nth -> Int -> Bool
instance GHC.Classes.Eq Text.XML.HXT.CSS.TypeDefs.SelectorsGroup
instance GHC.Show.Show Text.XML.HXT.CSS.TypeDefs.SelectorsGroup
instance GHC.Classes.Eq Text.XML.HXT.CSS.TypeDefs.Selector
instance GHC.Show.Show Text.XML.HXT.CSS.TypeDefs.Selector
instance GHC.Classes.Eq Text.XML.HXT.CSS.TypeDefs.SimpleSelectorSeq
instance GHC.Show.Show Text.XML.HXT.CSS.TypeDefs.SimpleSelectorSeq
instance GHC.Classes.Eq Text.XML.HXT.CSS.TypeDefs.SimpleSelector
instance GHC.Show.Show Text.XML.HXT.CSS.TypeDefs.SimpleSelector
instance GHC.Classes.Eq Text.XML.HXT.CSS.TypeDefs.PseudoNthClass
instance GHC.Show.Show Text.XML.HXT.CSS.TypeDefs.PseudoNthClass
instance GHC.Classes.Eq Text.XML.HXT.CSS.TypeDefs.Nth
instance GHC.Show.Show Text.XML.HXT.CSS.TypeDefs.Nth
instance GHC.Classes.Eq Text.XML.HXT.CSS.TypeDefs.PseudoClass
instance GHC.Show.Show Text.XML.HXT.CSS.TypeDefs.PseudoClass
instance GHC.Classes.Eq Text.XML.HXT.CSS.TypeDefs.AttrTest
instance GHC.Show.Show Text.XML.HXT.CSS.TypeDefs.AttrTest


-- | A parser for CSS selectors.
module Text.XML.HXT.CSS.Parser

-- | Parse a string to an AST. If the parser fails, it returns a left value
--   with an error message.
safeParseCSS :: String -> Either String SelectorsGroup

-- | Like <a>safeParseCSS</a>, but calls <a>error</a> if given an invalid
--   CSS selector.
parseCSS :: String -> SelectorsGroup


-- | Turn a CSS selector into an HXT arrow.
module Text.XML.HXT.CSS

-- | Select elements from an HTML document with a CSS selector.
css :: (ArrowXml a, Css s) => s -> a XmlTree XmlTree

-- | Like <a>css</a>, except that the selector is anchored at the top. For
--   example, <tt><a>cssShallow</a> "div"</tt> will only select
--   <tt>div</tt> elements that are in the input of the arrow, it will not
--   recursively search for <tt>div</tt>s contained deeper in the document
--   tree. The latter can be selected by <tt><a>cssShallow</a> "* div"</tt>
--   but is recommended to use <a>css</a> for that. In other words,
--   <tt><a>cssShallow</a> "div"</tt> corresponds to the <tt>"/div"</tt>
--   XPath expression, whereas <tt><a>cssShallow</a> "* div"</tt>
--   corresponds to <tt>"//div"</tt>.
cssShallow :: (ArrowXml a, Css s) => s -> a XmlTree XmlTree

-- | Like <a>css</a>, except that it operates on navigatable XML trees.
cssNav :: (ArrowXml a, Css s) => s -> a XmlNavTree XmlNavTree

-- | Like <a>cssShallow</a>, except that it operates on navigatable XML
--   trees.
cssShallowNav :: (ArrowXml a, Css s) => s -> a XmlNavTree XmlNavTree

-- | Things that can be used as a CSS selector. The <a>String</a> instance
--   uses <a>safeParseCSS</a> to parse the string.
class Css s where selectDeep s = multi (isElemN >>> select s)
instance Text.XML.HXT.CSS.Css [GHC.Types.Char]
instance Text.XML.HXT.CSS.Css Text.XML.HXT.CSS.TypeDefs.SelectorsGroup
instance Text.XML.HXT.CSS.Css Text.XML.HXT.CSS.TypeDefs.Selector
instance Text.XML.HXT.CSS.Css Text.XML.HXT.CSS.TypeDefs.SimpleSelectorSeq
instance Text.XML.HXT.CSS.Css Text.XML.HXT.CSS.TypeDefs.SimpleSelector
instance Text.XML.HXT.CSS.Css Text.XML.HXT.CSS.TypeDefs.PseudoClass
instance Text.XML.HXT.CSS.Css Text.XML.HXT.CSS.TypeDefs.PseudoNthClass
