-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Parsing, rendering and manipulating css selectors in Haskell. -- -- A library for parsing, manipulating, and rendering css selectors (not -- css files, just the selectors). -- -- It has a quasiquoter to enable Haskell to validate the css -- selector at compile time. -- -- Currently the css grammar is implemented without the -- pseudo-classes, pseudo-elements and negations. One can furthermore -- calculate the specificity of a css-selector, and thus perform an -- analysis over what css-selector will take precedence. @package css-selectors @version 0.2.0.0 -- | A module to encode and decode css selector strings. These are used in -- the parser and renderer to parse and render css selector strings. module Css.Selector.Utils -- | Parse a given css identifier to the content of the identifier. readIdentifier :: String -> String -- | Encode a given identifier to its css selector equivalent by escaping -- certain characters. encodeIdentifier :: Text -> Text -- | Check if the given identifier is a valid css selector identifier. isValidIdentifier :: String -> Bool -- | Convert the given string to a given object by first checking if it is -- a valid identifier, and if not raising an error. If it is a valid -- identifier, the string is packed, and wrapped in the given function. toIdentifier :: (Text -> a) -> String -> a -- | Parses a css string literal to a string that ontains the content of -- that string literal. readCssString :: String -> String -- | Convert a string to a css selector string literal. This is done by -- putting quotes around the content, and escaping certain characters. encodeString :: Char -> String -> String -- | Convert a string to a css selector string literal. This is done by -- putting quotes around the content, and escaping certain characters. encodeText :: Char -> Text -> Text -- | A module that defines the tree of types to represent and manipulate a -- css selector. These data types are members of several typeclasses to -- make these more useful. module Css.Selector.Core -- | A class that defines that the given type can be converted to a css -- selector value, and has a certain specificity. class ToCssSelector a -- | Convert the given element to a Text object that contains the -- css selector. toCssSelector :: ToCssSelector a => a -> Text -- | Lift the given ToCssSelector type object to a -- SelectorGroup, which is the "root type" of the css selector -- hierarchy. toSelectorGroup :: ToCssSelector a => a -> SelectorGroup -- | Calculate the specificity of the css selector by returing a -- SelectorSpecificity object. specificity' :: ToCssSelector a => a -> SelectorSpecificity toPattern :: ToCssSelector a => a -> Pat normalize :: ToCssSelector a => a -> a -- | The type of a single selector. This is a sequence of -- SelectorSequences that are combined with a -- SelectorCombinator. data Selector -- | Convert a given SelectorSequence to a Selector. Selector :: SelectorSequence -> Selector -- | Create a combined selector where we have a SelectorSequence -- that is combined with a given SelectorCombinator to a -- Selector. Combined :: SelectorSequence -> SelectorCombinator -> Selector -> Selector -- | A type that contains the possible ways to combine -- SelectorSequences. data SelectorCombinator -- | The second tag is a descendant of the first one, denoted in css with a -- space. Descendant :: SelectorCombinator -- | The second tag is the (direct) child of the first one, denoted with a -- > in css. Child :: SelectorCombinator -- | The second tag is directly preceded by the first one, denoted with a -- + in css. DirectlyPreceded :: SelectorCombinator -- | The second tag is preceded by the first one, denoted with a ~ -- in css. Preceded :: SelectorCombinator -- | The root type of a css selector. This is a comma-separated list of -- selectors. newtype SelectorGroup SelectorGroup :: NonEmpty Selector -> SelectorGroup -- | Unwrap the given NonEmpty list of Selectors from the -- SelectorGroup object. [unSelectorGroup] :: SelectorGroup -> NonEmpty Selector -- | A SelectorSequence is a TypeSelector (that can be -- Universal) followed by zero, one or more SelectorFilters -- these filter the selector further, for example with a Hash, a -- Class, or an Attrib. data SelectorSequence -- | Convert a TypeSelector into a SimpleSelector. SimpleSelector :: TypeSelector -> SelectorSequence -- | Apply an additional SelectorFilter to the -- SelectorSequence. Filter :: SelectorSequence -> SelectorFilter -> SelectorSequence -- | Convert the SelectorCombinator to the equivalent css selector -- text. A space for Descendant, a > for Child, -- a + for DirectlyPreceded, and a ~ for -- Preceded combinatorText :: SelectorCombinator -> Text -- | Combines two Selectors with the given -- SelectorCombinator. combine :: SelectorCombinator -> Selector -> Selector -> Selector -- | Combines two Selectors with the Child combinator. (.>) :: Selector -> Selector -> Selector -- | Combines two Selectors with the DirectlyPreceded -- combinator. (.+) :: Selector -> Selector -> Selector -- | Combines two Selectors with the Preceded combinator. (.~) :: Selector -> Selector -> Selector -- | A type that sums up the different ways to filter a type selector: with -- an id (hash), a class, and an attribute. data SelectorFilter -- | A Hash object as filter. SHash :: Hash -> SelectorFilter -- | A Class object as filter. SClass :: Class -> SelectorFilter -- | An Attrib object as filter. SAttrib :: Attrib -> SelectorFilter -- | Obtain the list of filters that are applied in the given -- SelectorSequence. filters :: SelectorSequence -> [SelectorFilter] -- | Obtain the list of filters that are applied in the given -- SelectorSequence in reversed order. filters' :: SelectorSequence -> [SelectorFilter] -- | Add a given list of SelectorFilters to the given -- SelectorSequence. The filters are applied left-to-right. addFilters :: SelectorSequence -> [SelectorFilter] -> SelectorSequence -- | An infix variant of the addFilters function. (.:) :: SelectorSequence -> [SelectorFilter] -> SelectorSequence -- | The namespace of a css selector tag. The namespace can be NAny -- (all possible namespaces), or a namespace with a given text (this text -- can be empty). data Namespace -- | A typeselector part that specifies that we accept all namespaces, in -- css denoted with *. NAny :: Namespace -- | A typselector part that specifies that we accept a certain namespace -- name. Namespace :: Text -> Namespace -- | The empty namespace. This is not the wildcard namespace -- (*). This is a bidirectional namespace and can thus be used -- in expressions as well. pattern NEmpty :: Namespace -- | The element name of a css selector tag. The element name can be -- EAny (all possible tag names), or an element name with a given -- text. data ElementName -- | A typeselector part that specifies that we accept all element names, -- in css denoted with *. EAny :: ElementName -- | A typeselector part that specifies that we accept a certain element -- name. ElementName :: Text -> ElementName -- | A typeselector is a combination of a selector for a namespace, and a -- selector for an element name. One, or both can be a wildcard. data TypeSelector TypeSelector :: Namespace -> ElementName -> TypeSelector -- | The selector for the namespace. [selectorNamespace] :: TypeSelector -> Namespace -- | The selector for the element name. [elementName] :: TypeSelector -> ElementName -- | The universal type selector: a selector that matches all types in all -- namespaces (including the empty namespace). This pattern is -- bidirectional and thus can be used in expressions as well. pattern Universal :: TypeSelector -- | Construct a TypeSelector with a given Namespace and -- ElementName. (.|) :: Namespace -> ElementName -> TypeSelector -- | A css attribute can come in two flavors: either a constraint that the -- attribute should exists, or a constraint that a certain attribute -- should have a certain value (prefix, suffix, etc.). data Attrib -- | A constraint that the given AttributeName should exist. Exist :: AttributeName -> Attrib -- | A constraint about the value associated with the given -- AttributeName. Attrib :: AttributeName -> AttributeCombinator -> AttributeValue -> Attrib -- | The possible ways to match an attribute with a given value in a css -- selector. data AttributeCombinator -- | The attribute has exactly the value of the value, denoted with -- = in css. Exact :: AttributeCombinator -- | The attribute has a whitespace separated list of items, one of these -- items is the value, denoted with ~= in css. Include :: AttributeCombinator -- | The attribute has a hyphen separated list of items, the first item is -- the value, denoted with |= in css. DashMatch :: AttributeCombinator -- | The value is a prefix of the value in the attribute, denoted with -- ^= in css. PrefixMatch :: AttributeCombinator -- | The value is a suffix of the value in the attribute, denoted with -- $= in css. SuffixMatch :: AttributeCombinator -- | The value is a substring of the value in the attribute, denoted with -- *= in css. SubstringMatch :: AttributeCombinator -- | An attribute name is a name that optionally has a namespace, and the -- name of the attribute. data AttributeName AttributeName :: Namespace -> Text -> AttributeName -- | The namespace to which the attribute name belongs. This can be -- NAny as well. [attributeNamespace] :: AttributeName -> Namespace -- | The name of the attribute over which we make a claim. [attributeName] :: AttributeName -> Text -- | We use Text as the type to store an attribute value. type AttributeValue = Text -- | Create an Attrib where the given AttributeName is -- constrainted to be exactly the given value. (.=) :: AttributeName -> AttributeValue -> Attrib -- | Create an Attrib where the given AttributeName is -- constrainted such that the attribute is a whitespace seperated list of -- items, and the value is one of these items. (.~=) :: AttributeName -> AttributeValue -> Attrib -- | Create an Attrib where the given AttributeName is -- constrainted such that the attribute is a dash seperated list of -- items, and the value is the first of these items. (.|=) :: AttributeName -> AttributeValue -> Attrib -- | Create an Attrib where the given AttributeName is -- constrainted such that the attribute has as prefix the given -- AttributeValue. (.^=) :: AttributeName -> AttributeValue -> Attrib -- | Create an Attrib where the given AttributeName is -- constrainted such that the attribute has as suffix the given -- AttributeValue. (.$=) :: AttributeName -> AttributeValue -> Attrib -- | Create an Attrib where the given AttributeName is -- constrainted such that the attribute has as substring the given -- AttributeValue. (.*=) :: AttributeName -> AttributeValue -> Attrib -- | A flipped version of the Attrib data constructor, where one -- first specifies the conbinator, then the AttributeName and -- finally the value. attrib :: AttributeCombinator -> AttributeName -> AttributeValue -> Attrib -- | Convert the given AttributeCombinator to its css selector -- counterpart. attributeCombinatorText :: AttributeCombinator -> AttributeValue -- | A css class, this is wrapped in a data type. The type only wraps the -- class name, not the dot prefix. newtype Class Class :: Text -> Class -- | Obtain the name from the class. [unClass] :: Class -> Text -- | Filter a given SelectorSequence with a given Class. (...) :: SelectorSequence -> Class -> SelectorSequence -- | A css hash (used to match an element with a given id). The type only -- wraps the hash name, not the hash (#) prefix. newtype Hash Hash :: Text -> Hash -- | Obtain the name from the hash. [unHash] :: Hash -> Text -- | Filter a given SelectorSequence with a given Hash. (.#) :: SelectorSequence -> Hash -> SelectorSequence -- | A datastructure that specifies the selectivity of a css selector. The -- specificity is calculated based on three integers: a, -- b and c. -- -- The specificity is calculated with 100*a+10*b+c where -- a, b and c count certain elements of the -- css selector. data SelectorSpecificity -- | Create a SelectorSpecificity object with a given value for -- a, b, and c. SelectorSpecificity :: Int -> Int -> Int -> SelectorSpecificity -- | Calculate the specificity of a ToCssSelector type object. This -- is done by calculating the SelectorSpecificity object, and then -- calculating the value of that object. specificity :: ToCssSelector a => a -> Int -- | Calculate the specificity value of the SelectorSpecificity specificityValue :: SelectorSpecificity -> Int instance GHC.Show.Show Css.Selector.Core.SelectorGroup instance GHC.Classes.Ord Css.Selector.Core.SelectorGroup instance GHC.Classes.Eq Css.Selector.Core.SelectorGroup instance Data.Data.Data Css.Selector.Core.SelectorGroup instance GHC.Show.Show Css.Selector.Core.Selector instance GHC.Classes.Ord Css.Selector.Core.Selector instance GHC.Classes.Eq Css.Selector.Core.Selector instance Data.Data.Data Css.Selector.Core.Selector instance GHC.Show.Show Css.Selector.Core.SelectorSequence instance GHC.Classes.Ord Css.Selector.Core.SelectorSequence instance GHC.Classes.Eq Css.Selector.Core.SelectorSequence instance Data.Data.Data Css.Selector.Core.SelectorSequence instance GHC.Show.Show Css.Selector.Core.SelectorFilter instance GHC.Classes.Ord Css.Selector.Core.SelectorFilter instance GHC.Classes.Eq Css.Selector.Core.SelectorFilter instance Data.Data.Data Css.Selector.Core.SelectorFilter instance GHC.Show.Show Css.Selector.Core.Hash instance GHC.Classes.Ord Css.Selector.Core.Hash instance GHC.Classes.Eq Css.Selector.Core.Hash instance Data.Data.Data Css.Selector.Core.Hash instance GHC.Show.Show Css.Selector.Core.Class instance GHC.Classes.Ord Css.Selector.Core.Class instance GHC.Classes.Eq Css.Selector.Core.Class instance Data.Data.Data Css.Selector.Core.Class instance GHC.Show.Show Css.Selector.Core.Attrib instance GHC.Classes.Ord Css.Selector.Core.Attrib instance GHC.Classes.Eq Css.Selector.Core.Attrib instance Data.Data.Data Css.Selector.Core.Attrib instance GHC.Show.Show Css.Selector.Core.AttributeCombinator instance GHC.Read.Read Css.Selector.Core.AttributeCombinator instance GHC.Classes.Ord Css.Selector.Core.AttributeCombinator instance GHC.Classes.Eq Css.Selector.Core.AttributeCombinator instance GHC.Enum.Enum Css.Selector.Core.AttributeCombinator instance Data.Data.Data Css.Selector.Core.AttributeCombinator instance GHC.Enum.Bounded Css.Selector.Core.AttributeCombinator instance GHC.Show.Show Css.Selector.Core.AttributeName instance GHC.Classes.Ord Css.Selector.Core.AttributeName instance GHC.Classes.Eq Css.Selector.Core.AttributeName instance Data.Data.Data Css.Selector.Core.AttributeName instance GHC.Show.Show Css.Selector.Core.TypeSelector instance GHC.Classes.Ord Css.Selector.Core.TypeSelector instance GHC.Classes.Eq Css.Selector.Core.TypeSelector instance Data.Data.Data Css.Selector.Core.TypeSelector instance GHC.Show.Show Css.Selector.Core.ElementName instance GHC.Classes.Ord Css.Selector.Core.ElementName instance GHC.Classes.Eq Css.Selector.Core.ElementName instance Data.Data.Data Css.Selector.Core.ElementName instance GHC.Show.Show Css.Selector.Core.Namespace instance GHC.Classes.Ord Css.Selector.Core.Namespace instance GHC.Classes.Eq Css.Selector.Core.Namespace instance Data.Data.Data Css.Selector.Core.Namespace instance GHC.Show.Show Css.Selector.Core.SelectorCombinator instance GHC.Read.Read Css.Selector.Core.SelectorCombinator instance GHC.Classes.Ord Css.Selector.Core.SelectorCombinator instance GHC.Classes.Eq Css.Selector.Core.SelectorCombinator instance GHC.Enum.Enum Css.Selector.Core.SelectorCombinator instance Data.Data.Data Css.Selector.Core.SelectorCombinator instance GHC.Enum.Bounded Css.Selector.Core.SelectorCombinator instance GHC.Show.Show Css.Selector.Core.SelectorSpecificity instance Data.Data.Data Css.Selector.Core.SelectorSpecificity instance Css.Selector.Core.ToCssSelector Css.Selector.Core.SelectorGroup instance Css.Selector.Core.ToCssSelector Css.Selector.Core.Class instance Css.Selector.Core.ToCssSelector Css.Selector.Core.Attrib instance Css.Selector.Core.ToCssSelector Css.Selector.Core.AttributeName instance Css.Selector.Core.ToCssSelector Css.Selector.Core.Hash instance Css.Selector.Core.ToCssSelector Css.Selector.Core.Namespace instance Css.Selector.Core.ToCssSelector Css.Selector.Core.SelectorSequence instance Css.Selector.Core.ToCssSelector Css.Selector.Core.TypeSelector instance Css.Selector.Core.ToCssSelector Css.Selector.Core.ElementName instance Css.Selector.Core.ToCssSelector Css.Selector.Core.SelectorFilter instance Css.Selector.Core.ToCssSelector Css.Selector.Core.Selector instance GHC.Base.Semigroup Css.Selector.Core.SelectorGroup instance GHC.Exts.IsList Css.Selector.Core.SelectorGroup instance Data.Default.Class.Default Css.Selector.Core.SelectorGroup instance Language.Haskell.TH.Syntax.Lift Css.Selector.Core.SelectorGroup instance Text.Blaze.ToMarkup Css.Selector.Core.SelectorGroup instance Text.Julius.ToJavascript Css.Selector.Core.SelectorGroup instance Data.Aeson.Types.ToJSON.ToJSON Css.Selector.Core.SelectorGroup instance Test.QuickCheck.Arbitrary.Arbitrary Css.Selector.Core.SelectorGroup instance GHC.Base.Semigroup Css.Selector.Core.Selector instance Data.Default.Class.Default Css.Selector.Core.Selector instance Language.Haskell.TH.Syntax.Lift Css.Selector.Core.Selector instance Text.Blaze.ToMarkup Css.Selector.Core.Selector instance Text.Julius.ToJavascript Css.Selector.Core.Selector instance Data.Aeson.Types.ToJSON.ToJSON Css.Selector.Core.Selector instance Test.QuickCheck.Arbitrary.Arbitrary Css.Selector.Core.Selector instance Data.Default.Class.Default Css.Selector.Core.SelectorSequence instance Language.Haskell.TH.Syntax.Lift Css.Selector.Core.SelectorSequence instance Text.Blaze.ToMarkup Css.Selector.Core.SelectorSequence instance Text.Julius.ToJavascript Css.Selector.Core.SelectorSequence instance Data.Aeson.Types.ToJSON.ToJSON Css.Selector.Core.SelectorSequence instance Test.QuickCheck.Arbitrary.Arbitrary Css.Selector.Core.SelectorSequence instance Language.Haskell.TH.Syntax.Lift Css.Selector.Core.SelectorFilter instance Text.Blaze.ToMarkup Css.Selector.Core.SelectorFilter instance Text.Julius.ToJavascript Css.Selector.Core.SelectorFilter instance Data.Aeson.Types.ToJSON.ToJSON Css.Selector.Core.SelectorFilter instance Test.QuickCheck.Arbitrary.Arbitrary Css.Selector.Core.SelectorFilter instance Data.String.IsString Css.Selector.Core.Hash instance Test.QuickCheck.Arbitrary.Arbitrary Css.Selector.Core.Hash instance Data.String.IsString Css.Selector.Core.Class instance Test.QuickCheck.Arbitrary.Arbitrary Css.Selector.Core.Class instance Data.String.IsString Css.Selector.Core.Attrib instance Language.Haskell.TH.Syntax.Lift Css.Selector.Core.Attrib instance Text.Blaze.ToMarkup Css.Selector.Core.Attrib instance Text.Julius.ToJavascript Css.Selector.Core.Attrib instance Data.Aeson.Types.ToJSON.ToJSON Css.Selector.Core.Attrib instance Test.QuickCheck.Arbitrary.Arbitrary Css.Selector.Core.Attrib instance Data.Default.Class.Default Css.Selector.Core.AttributeCombinator instance Test.QuickCheck.Arbitrary.Arbitrary Css.Selector.Core.AttributeCombinator instance Data.String.IsString Css.Selector.Core.AttributeName instance Test.QuickCheck.Arbitrary.Arbitrary Css.Selector.Core.AttributeName instance Data.Default.Class.Default Css.Selector.Core.TypeSelector instance Test.QuickCheck.Arbitrary.Arbitrary Css.Selector.Core.TypeSelector instance GHC.Base.Semigroup Css.Selector.Core.ElementName instance GHC.Base.Monoid Css.Selector.Core.ElementName instance Data.String.IsString Css.Selector.Core.ElementName instance Data.Default.Class.Default Css.Selector.Core.ElementName instance Test.QuickCheck.Arbitrary.Arbitrary Css.Selector.Core.ElementName instance GHC.Base.Semigroup Css.Selector.Core.Namespace instance GHC.Base.Monoid Css.Selector.Core.Namespace instance Data.String.IsString Css.Selector.Core.Namespace instance Data.Default.Class.Default Css.Selector.Core.Namespace instance Test.QuickCheck.Arbitrary.Arbitrary Css.Selector.Core.Namespace instance Data.Default.Class.Default Css.Selector.Core.SelectorCombinator instance Language.Haskell.TH.Syntax.Lift Css.Selector.Core.SelectorCombinator instance Test.QuickCheck.Arbitrary.Arbitrary Css.Selector.Core.SelectorCombinator instance GHC.Base.Semigroup Css.Selector.Core.SelectorSpecificity instance GHC.Base.Monoid Css.Selector.Core.SelectorSpecificity instance GHC.Classes.Eq Css.Selector.Core.SelectorSpecificity instance GHC.Classes.Ord Css.Selector.Core.SelectorSpecificity instance Data.Default.Class.Default Css.Selector.Core.SelectorSpecificity -- | A module that defines a quasiquoter to parse a string to a css -- selector. module Css.Selector.QuasiQuoters -- | A quasiquoter that can be used to construct a SelectorGroup for -- the given css selector. In case the css selector is invalid. A -- compiler error will be thrown (at compile time). csssel :: QuasiQuoter -- | A quasiquoter that takes the content from the file, and then runs the -- content of that file as a csssel quasiquote. cssselFile :: QuasiQuoter -- | Parse the string to a SelectorGroup. parseCss :: String -> SelectorGroup -- | A module to define css selectors by making use of a quasiquoter, and -- manipulating these css selectors. module Css.Selector