Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Wrapper over the HaXPath module which supports stronger type gurantuees such that XPaths must be valid with respect to the document schema. This module should be used as a qualified import.
Synopsis
- class ToNonSchematic t where
- type NonSchematic t
- toNonSchematic :: t -> NonSchematic t
- data Bool' (as :: [Type]) s
- type Bool as = Bool' as String
- false :: IsString s => Bool' as s
- true :: IsString s => Bool' as s
- data Number' (as :: [Type]) s
- type Number as = Number' as String
- data Text' (as :: [Type]) s
- type Text as = Text' as String
- text :: forall (as :: [Type]) s. IsString s => Text' as s
- data Node' (n :: Type) s
- type Node n = Node' n String
- class IsNode n where
- namedNode :: forall n s. (IsNode n, IsString s) => Node' n s
- data DocumentRoot' sc s
- root' :: DocumentRoot' sc s
- type DocumentRoot sc = DocumentRoot' sc String
- root :: DocumentRoot sc
- type family Attributes n :: [Type]
- type family AttributesUsed t where ...
- class IsAttribute a where
- attributeName :: IsString s => proxy a -> s
- at :: (IsAttribute a, Member a as, IsString s) => proxy a -> Text' as s
- not :: IsString s => Bool' as s -> Bool' as s
- (&&.) :: IsString s => Bool' as s -> Bool' as s -> Bool' as s
- (||.) :: IsString s => Bool' as s -> Bool' as s -> Bool' as s
- (=.) :: (ToNonSchematic t, Eq (NonSchematic t), IsString (Showed (NonSchematic t))) => t -> t -> Bool' (AttributesUsed t) (Showed (NonSchematic t))
- (/=.) :: (ToNonSchematic t, Eq (NonSchematic t), IsString (Showed (NonSchematic t))) => t -> t -> Bool' (AttributesUsed t) (Showed (NonSchematic t))
- (<.) :: (ToNonSchematic t, Ord (NonSchematic t), IsString (Showed (NonSchematic t))) => t -> t -> Bool' (AttributesUsed t) (Showed (NonSchematic t))
- (<=.) :: (ToNonSchematic t, Ord (NonSchematic t), IsString (Showed (NonSchematic t))) => t -> t -> Bool' (AttributesUsed t) (Showed (NonSchematic t))
- (>.) :: (ToNonSchematic t, Ord (NonSchematic t), IsString (Showed (NonSchematic t))) => t -> t -> Bool' (AttributesUsed t) (Showed (NonSchematic t))
- (>=.) :: (ToNonSchematic t, Ord (NonSchematic t), IsString (Showed (NonSchematic t))) => t -> t -> Bool' (AttributesUsed t) (Showed (NonSchematic t))
- contains :: IsString s => Text' as s -> Text' as s -> Bool' as s
- doesNotContain :: IsString s => Text' as s -> Text' as s -> Bool' as s
- position :: IsString s => Number' as s
- data Path' c axis n rn s
- type Path c axis n rn = Path' c axis n rn String
- type AbsolutePath' sc rn = Path' RootContext Self (DocumentRoot sc) rn
- type AbsolutePath sc rn = AbsolutePath' sc rn String
- type RelativePath' = Path' CurrentContext
- type RelativePath axis n rn = RelativePath' axis n rn String
- type PathLike p = (ToNonSchematic p, PathLike (NonSchematic p))
- type family SelectNode p where ...
- type family ReturnNode p where ...
- type family Relatives n axis :: [Type]
- show' :: (PathLike p, IsExpression (NonSchematic p), Monoid (Showed (NonSchematic p)), IsString (Showed (NonSchematic p)), Show (Showed (NonSchematic p))) => p -> Showed (NonSchematic p)
- show :: (PathLike p, Showed (NonSchematic p) ~ String, IsExpression (NonSchematic p)) => p -> String
- type family Axis p where ...
- data Ancestor
- ancestor :: Node' n s -> Path' CurrentContext Ancestor n n s
- data Child
- child :: Node' n s -> Path' CurrentContext Child n n s
- data Descendant
- descendant :: Node' n s -> Path' CurrentContext Descendant n n s
- data DescendantOrSelf
- descendantOrSelf :: Node' n s -> Path' CurrentContext DescendantOrSelf n n s
- data Following
- following :: Node' n s -> Path' CurrentContext Following n n s
- data FollowingSibling
- followingSibling :: Node' n s -> Path' CurrentContext FollowingSibling n n s
- data Parent
- parent :: Node' n s -> Path' CurrentContext Parent n n s
- (/.) :: (Member (SelectNode q) (Relatives (ReturnNode p) (Axis q)), PathLike p, PathLike q, SlashOperator (NonSchematic p) (NonSchematic q)) => p -> q -> Path' (Context (NonSchematic p)) (Axis p) (SelectNode p) (ReturnNode q) (Showed (NonSchematic q))
- (//.) :: (Member (SelectNode q) (Relatives (ReturnNode p) Descendant), PathLike p, PathLike q, DoubleSlashOperator (NonSchematic p) (NonSchematic q)) => p -> q -> Path' (Context (NonSchematic p)) (Axis p) (SelectNode p) (ReturnNode q) (Showed (NonSchematic q))
- (#) :: (PathLike p, ToNonSchematic p, FromNonSchematic (NonSchematic p) p, Filterable (NonSchematic p)) => p -> [Bool' (Attributes (ReturnNode p)) (Showed (NonSchematic p))] -> p
- count :: (IsContext c, IsString s) => Path' c axis n rn s -> Number' as s
- type Member x xs = HMember x xs 'True
Basic data types
class ToNonSchematic t where Source #
Type class for conversion from a schematic value to its underlying, non-schematic version.
type NonSchematic t Source #
Corresponding non-schematic type.
toNonSchematic :: t -> NonSchematic t Source #
Convert from the schematic to the non-schematic version.
Instances
data Bool' (as :: [Type]) s Source #
The type of boolean expressions which depend on the value of the attribute(s) as
and can be showed as the string
type s
.
Instances
ToNonSchematic (Bool' as s) Source # | |
Defined in HaXPath.Schematic type NonSchematic (Bool' as s) Source # toNonSchematic :: Bool' as s -> NonSchematic (Bool' as s) Source # | |
type NonSchematic (Bool' as s) Source # | |
Defined in HaXPath.Schematic |
data Number' (as :: [Type]) s Source #
The type of simple numeric expressions which depend on the value of the attribute(s) as
and can be showed as the
string type s
.
Instances
ToNonSchematic (Number' as s) Source # | |
Defined in HaXPath.Schematic type NonSchematic (Number' as s) Source # toNonSchematic :: Number' as s -> NonSchematic (Number' as s) Source # | |
IsString s => Num (Number' a s) Source # | |
Defined in HaXPath.Schematic (+) :: Number' a s -> Number' a s -> Number' a s # (-) :: Number' a s -> Number' a s -> Number' a s # (*) :: Number' a s -> Number' a s -> Number' a s # negate :: Number' a s -> Number' a s # abs :: Number' a s -> Number' a s # signum :: Number' a s -> Number' a s # fromInteger :: Integer -> Number' a s # | |
type NonSchematic (Number' as s) Source # | |
Defined in HaXPath.Schematic |
data Text' (as :: [Type]) s Source #
The type of simple text expressions which depend on the value of the attribute(s) as
and can be showed as the
string type s
.
Instances
ToNonSchematic (Text' as s) Source # | |
Defined in HaXPath.Schematic type NonSchematic (Text' as s) Source # toNonSchematic :: Text' as s -> NonSchematic (Text' as s) Source # | |
IsString s => IsString (Text' as s) Source # | |
Defined in HaXPath.Schematic fromString :: String -> Text' as s # | |
type NonSchematic (Text' as s) Source # | |
Defined in HaXPath.Schematic |
Nodes
data Node' (n :: Type) s Source #
Type of an XPath node of type n
which can be showed as the string type s
.
Instances
ToNonSchematic (Node' n s) Source # | |
Defined in HaXPath.Schematic type NonSchematic (Node' n s) Source # toNonSchematic :: Node' n s -> NonSchematic (Node' n s) Source # | |
type NonSchematic (Node' n s) Source # | |
Defined in HaXPath.Schematic |
Type class of node types.
namedNode :: forall n s. (IsNode n, IsString s) => Node' n s Source #
Create a node expression of the given type.
data DocumentRoot' sc s Source #
Type of the document root for the schema sc
which can be showed as the string type s
. Useful in forming an
XPaths which must begin from the root.
Instances
ToNonSchematic (DocumentRoot' sc s) Source # | |
Defined in HaXPath.Schematic type NonSchematic (DocumentRoot' sc s) Source # toNonSchematic :: DocumentRoot' sc s -> NonSchematic (DocumentRoot' sc s) Source # | |
type NonSchematic (DocumentRoot' sc s) Source # | |
Defined in HaXPath.Schematic | |
type Relatives (DocumentRoot' sc s) Ancestor Source # | |
Defined in HaXPath.Schematic | |
type Relatives (DocumentRoot' sc s) Following Source # | |
Defined in HaXPath.Schematic | |
type Relatives (DocumentRoot' sc s) FollowingSibling Source # | |
Defined in HaXPath.Schematic | |
type Relatives (DocumentRoot' sc s) Parent Source # | |
Defined in HaXPath.Schematic |
root' :: DocumentRoot' sc s Source #
The root of the document for the schema s
.
type DocumentRoot sc = DocumentRoot' sc String Source #
DocumentRoot'
specialised so it can be shown as String
.
type family Attributes n :: [Type] Source #
Type family which contrains the possible attributes a node of type n
may have.
type family AttributesUsed t where ... Source #
Type family which returns the node attribute(s) used within a given expression.
AttributesUsed (Bool' as s) = as | |
AttributesUsed (Text' as s) = as | |
AttributesUsed (Number' as s) = as |
class IsAttribute a where Source #
Type class for node attributes.
attributeName :: IsString s => proxy a -> s Source #
Return the name of the attribute.
at :: (IsAttribute a, Member a as, IsString s) => proxy a -> Text' as s Source #
Access the value of the attribute a
of a node (equivalent to XPath's @
).
Basic combinators
(&&.) :: IsString s => Bool' as s -> Bool' as s -> Bool' as s infixr 3 Source #
The XPath and
operator.
(||.) :: IsString s => Bool' as s -> Bool' as s -> Bool' as s infixr 2 Source #
The XPath or
operator.
(=.) :: (ToNonSchematic t, Eq (NonSchematic t), IsString (Showed (NonSchematic t))) => t -> t -> Bool' (AttributesUsed t) (Showed (NonSchematic t)) infix 4 Source #
The XPath =
operator.
(/=.) :: (ToNonSchematic t, Eq (NonSchematic t), IsString (Showed (NonSchematic t))) => t -> t -> Bool' (AttributesUsed t) (Showed (NonSchematic t)) infix 4 Source #
The XPath !=
operator.
(<.) :: (ToNonSchematic t, Ord (NonSchematic t), IsString (Showed (NonSchematic t))) => t -> t -> Bool' (AttributesUsed t) (Showed (NonSchematic t)) infix 4 Source #
The XPath <
operator.
(<=.) :: (ToNonSchematic t, Ord (NonSchematic t), IsString (Showed (NonSchematic t))) => t -> t -> Bool' (AttributesUsed t) (Showed (NonSchematic t)) infix 4 Source #
The XPath <=
operator.
(>.) :: (ToNonSchematic t, Ord (NonSchematic t), IsString (Showed (NonSchematic t))) => t -> t -> Bool' (AttributesUsed t) (Showed (NonSchematic t)) infix 4 Source #
The XPath >
operator.
(>=.) :: (ToNonSchematic t, Ord (NonSchematic t), IsString (Showed (NonSchematic t))) => t -> t -> Bool' (AttributesUsed t) (Showed (NonSchematic t)) infix 4 Source #
The XPath >=
operator.
contains :: IsString s => Text' as s -> Text' as s -> Bool' as s Source #
The XPath contains()
function.
doesNotContain :: IsString s => Text' as s -> Text' as s -> Bool' as s Source #
The opposite of contains
.
Paths
data Path' c axis n rn s Source #
The type of path expressions which can be showed as the string type s
and are formed by these steps:
- Starting from the context
c
and moving through the givenaxis
. - Selecting node(s) of type
n
. - Performing zero or more location steps.
- Finally returning the node(s) of type
rn
.
Instances
ToNonSchematic (Path' c axis n rn s) Source # | |
Defined in HaXPath.Schematic type NonSchematic (Path' c axis n rn s) Source # toNonSchematic :: Path' c axis n rn s -> NonSchematic (Path' c axis n rn s) Source # | |
type NonSchematic (Path' c axis n rn s) Source # | |
Defined in HaXPath.Schematic |
type AbsolutePath' sc rn = Path' RootContext Self (DocumentRoot sc) rn Source #
An XPath beginning from the document root for the schema sc
, returning a node of type rn
.
type AbsolutePath sc rn = AbsolutePath' sc rn String Source #
AbsolutePath'
specialised so it can be shown as String
type RelativePath' = Path' CurrentContext Source #
An XPath beginning from the current context.
type RelativePath axis n rn = RelativePath' axis n rn String Source #
RelativePath'
specialised so it can be shown as String
type PathLike p = (ToNonSchematic p, PathLike (NonSchematic p)) Source #
Constraint for types from which a path can be inferred.
type family SelectNode p where ... Source #
Type family to infer the type of the node selected by the first location step in a path.
SelectNode (Path' c axis n rn s) = n | |
SelectNode (Node' n s) = n | |
SelectNode (DocumentRoot' sc s) = DocumentRoot' sc s |
type family ReturnNode p where ... Source #
Type family to infer the node selected by the last location step in a path.
ReturnNode (Path' c axis n rn s) = rn | |
ReturnNode (Node' n s) = n | |
ReturnNode (DocumentRoot' sc s) = DocumentRoot' sc s |
type family Relatives n axis :: [Type] Source #
Type family to constrain the possible relatives of nodes of type n
through the given axis.
Instances
type Relatives (DocumentRoot' sc s) Ancestor Source # | |
Defined in HaXPath.Schematic | |
type Relatives (DocumentRoot' sc s) Following Source # | |
Defined in HaXPath.Schematic | |
type Relatives (DocumentRoot' sc s) FollowingSibling Source # | |
Defined in HaXPath.Schematic | |
type Relatives (DocumentRoot' sc s) Parent Source # | |
Defined in HaXPath.Schematic |
show' :: (PathLike p, IsExpression (NonSchematic p), Monoid (Showed (NonSchematic p)), IsString (Showed (NonSchematic p)), Show (Showed (NonSchematic p))) => p -> Showed (NonSchematic p) Source #
Display an XPath expression. This is useful for sending the XPath expression to a separate XPath evaluator e.g. a web browser.
show :: (PathLike p, Showed (NonSchematic p) ~ String, IsExpression (NonSchematic p)) => p -> String Source #
Axes
type family Axis p where ... Source #
Type family to infer of the axis of a location step based on the type of the step.
Type of the XPath ancestor::
axis.
Instances
type Relatives (DocumentRoot' sc s) Ancestor Source # | |
Defined in HaXPath.Schematic |
data Descendant Source #
Type of the XPath descendant::
axis.
descendant :: Node' n s -> Path' CurrentContext Descendant n n s Source #
The XPath descendant::
axis.
data DescendantOrSelf Source #
Type of the XPath descendant-or-self::
axis.
descendantOrSelf :: Node' n s -> Path' CurrentContext DescendantOrSelf n n s Source #
The XPath descendant-or-self::
axis.
Type of the XPath following::
axis.
Instances
type Relatives (DocumentRoot' sc s) Following Source # | |
Defined in HaXPath.Schematic |
data FollowingSibling Source #
Type of the XPath following-sibling::
axis.
Instances
type Relatives (DocumentRoot' sc s) FollowingSibling Source # | |
Defined in HaXPath.Schematic |
followingSibling :: Node' n s -> Path' CurrentContext FollowingSibling n n s Source #
The XPath following-sibling::
axis.
Type of the XPath parent::
axis.
Instances
type Relatives (DocumentRoot' sc s) Parent Source # | |
Defined in HaXPath.Schematic |
Path combinators
(/.) :: (Member (SelectNode q) (Relatives (ReturnNode p) (Axis q)), PathLike p, PathLike q, SlashOperator (NonSchematic p) (NonSchematic q)) => p -> q -> Path' (Context (NonSchematic p)) (Axis p) (SelectNode p) (ReturnNode q) (Showed (NonSchematic q)) infixl 8 Source #
The XPath /
operator.
(//.) :: (Member (SelectNode q) (Relatives (ReturnNode p) Descendant), PathLike p, PathLike q, DoubleSlashOperator (NonSchematic p) (NonSchematic q)) => p -> q -> Path' (Context (NonSchematic p)) (Axis p) (SelectNode p) (ReturnNode q) (Showed (NonSchematic q)) infixl 8 Source #
The XPath //
operator.
(#) :: (PathLike p, ToNonSchematic p, FromNonSchematic (NonSchematic p) p, Filterable (NonSchematic p)) => p -> [Bool' (Attributes (ReturnNode p)) (Showed (NonSchematic p))] -> p infixl 9 Source #
Filter the path-like expression using the given predicate(s). The predicates must only make use of the attributes of the type of node selected by the path, otherwise it will not type check.
count :: (IsContext c, IsString s) => Path' c axis n rn s -> Number' as s Source #
The XPath count()
function.