h$.V      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcde f g h i j k l m n o p q r s t u v w x y z { | } ~                                                                                                                                                  !!!!"""""""""""""""""""""""""""##$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$%%%%%%%%%%%%%%%%%%%%%%&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&'''''''''''''''''''''''''''''''''' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ( ( ) ) ) ) ) ) ) ) ) ) ) ) * * * * * * * * * * * * * * * * * * * * * * * * * * + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + , , - . . . . . . . . . . . . . . . . / 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 4 4 5 6 7 7 8 8 8 8 8 8 8 9 9 9 9 9 9 9 : : : : : : : : : : : : : : : ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; < = > > > > > > > ? ? ? ? ? ? ? ? ? ? ? ? ? @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ A A A A A A A A A A A A A A A A A A A A B B B B B B C D D D D D E E E E F F G G G G G G G H H H H H H H H I J J J J J J J J J J J J J J J J J J J J J J J J J J J J J J J J J J J J J J J J J J J J J J J J J J J J J J J J J K K K K K K K K K K K K K K K K K K K K K K K K K K K K K K K K K K K K K K K K K K K K K K K K K K K K K K K K K K L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L L M MMMMMMMMMMMMMMMMMMMMMMNNNNNNNNNCopyright (C) 2005 Uwe SchmidtMITUwe Schmidt (uwe\@fh-wedel.de) experimentalportable Safe-Inferred3>&hxt>the interface for converting an IO predicate into a list arrowhxt$builds an arrow from an IO predicateif the predicate holds, the single list containing the input is returned, else the empty list, similar to Ohxt7the interface for converting an IO action into an arrowhxt$construct an arrow from an IO actionhxt:construct an arrow from an IO action without any parameterhxtconstruction of a 2 argument arrow from a binary IO action | | example:  a1 &&& a2 >>> arr2 f hxtconstruction of a 3 argument arrow from a 3-ary IO action | | example:  a1 &&& a2 &&& a3 >>> arr3 f hxtconstruction of a 4 argument arrow from a 4-ary IO action | | example: $ a1 &&& a2 &&& a3 &&& a4 >>> arr4 f Copyright (C) 2010 Uwe SchmidtMITUwe Schmidt (uwe\@fh-wedel.de) experimental not portable Safe-Inferred3>'H  Copyright (C) 2005 Uwe SchmidtMITUwe Schmidt (uwe\@fh-wedel.de) experimentalportable Safe-Inferred3>C9 hxtThe interface for list arrowsOnly mkA,  # don't have default implementations hxtconstruction of a 2 argument arrow from a binary function | | example:  a1 &&& a2 >>> arr2 f hxtconstruction of a 3 argument arrow from a 3-ary function | | example:  a1 &&& a2 &&& a3 >>> arr3 f hxtconstruction of a 4 argument arrow from a 4-ary function | | example: $ a1 &&& a2 &&& a3 &&& a4 >>> arr4 f hxt>construction of a 2 argument arrow from a singe argument arrowhxtconstructor for a list arrow from a function with a list as resulthxt-constructor for a list arrow with 2 argumentshxtconstructor for a const arrow:  constA = arr . const hxtconstructor for a const arrow:  constL = arrL . const hxtbuilds an arrow from a predicate. If the predicate holds, the single list containing the input is returned, else the empty listhxtcombinator for converting the result of a list arrow into another list example:  foo >>. reverse  reverses the the result of foo example:  foo >>. take 1  constructs a deterministic version of foo by deleting all further resultshxtcombinator for converting the result of an arrow into a single element resulthxtcombinator for converting an arrow into a determinstic version with all results collected in a single element list  listA af = af >>. (:[])this is useful when the list of results computed by an arrow must be manipulated (e.g. sorted)+example for sorting the results of a filter collectAndSort :: a b c -> a b c collectAndSort collect = listA collect >>> arrL sorthxtthe inverse of   listA af >>> unlistA = afunlistA is defined as  arrL id hxt%the identity arrow, alias for returnAhxt#the zero arrow, alias for zeroArrowhxtconverts an arrow, that may fail, into an arrow that always succeeds example:  withDefault none "abc"  is equivalent to  constA "abc" hxtmakes a list arrow deterministic, the number of results is at most 1 definition single f = f >>. take 1examples with strings: runLA ( single none ) "x" == [] runLA ( single this ) "x" == ["x"] runLA ( single (constA "y" <+> this ) ) "x" == ["y"]hxtcompute an arrow from the input and apply the arrow to this input definition:  (f &&& this) >>> app in a point free style, there is no way to use an argument in 2 places, this is a combinator for simulating this. first the argument is used to compute an arrow, then this new arrow is applied to the inputapplyA coresponds to:  apply f x = let g = f x in g x  see also: , ,  , !, "hxtcompute the parameter for an arrow with extra parameters from the input and apply the arrow for all parameter values to the input?a kind of "function call" for arrows, useful for joining arrows  infixl 2 ($<) definition: g $< f = applyA (f >>> arr g)if f$ fails, the whole arrow fails, e.g.  g $< none == none if f computes n values and g4 is deterministic, the whole arrow computes n values-examples with simple list arrows with strings prefixString :: String -> a String String prefixString s = arr (s++) runLA ( prefixString $< none ) "x" == [] runLA ( prefixString $< constA "y" ) "x" == ["yx"] runLA ( prefixString $< this ) "x" == ["xx"] runLA ( prefixString $< constA "y" <+> constA "z" ) "x" == ["yx","zx"] runLA ( prefixString $< constA "y" <+> this <+> constA "z" ) "x" == ["yx","xx","zx"] see also: , ,  , !, "hxtbinary version of ,example with simple list arrows with strings infixString :: String -> String -> a String String infixString s1 s2 = arr (\ s -> s1 ++ s ++ s2) runLA ( infixString $<< constA "y" &&& constA "z" ) "x" = ["yxz"] runLA ( infixString $<< this &&& this ) "x" = ["xxx"] runLA ( infixString $<< constA "y" &&& (constA "z" <+> this) ) "x" = ["yxz", "yxx"] hxt version of # for arrows with 3 extra parameters typical usage f $<<< g1 &&& g2 &&& g3!hxt version of # for arrows with 4 extra parameters typical usage f $<<<< g1 &&& g2 &&& g3 &&& g4"hxt#compute the parameter for an arrow f% with an extra parameter by an arrow g! and apply all the results from g sequentially to the input infixl 2 ($<$)typical usage:  a b b f x = ... x ... f $<$ gf# computes the extra parameters for g from the input of type b and g is applied with this parameter to the input. This allows programming in a point wise style in g, which becomes neccessary, when a value is needed more than once.this combinator is useful, when transforming a single value (document) step by step, with g, for collecting the data for all steps, and f( for transforming the input step by stepif g2 is deterministic (computes exactly one result),  g $<$ f == g $< f  holdsif g fails,  f $<$ g == this if g computes more than one result, f< is applied sequentially to the input for every result from g-examples with simple list arrows with strings prefixString :: String -> a String String prefixString s = arr (s++) runLA ( prefixString $<$ none ) "x" == ["x"] runLA ( prefixString $<$ constA "y" ) "x" == ["yx"] runLA ( prefixString $<$ constA "y" <+> constA "z" ) "x" == ["zyx"] runLA ( prefixString $<$ constA "y" <+> this <+> constA "z" ) "x" == ["zxyx"] example with two extra parameter g1 :: a b c1 g2 :: a b c2 f :: (c1, c2) -> a b b f (x1, x2) = ... x1 ... x2 ... f $<$ g1 &&& g2 see also: , #hxt-merge the result pairs of an arrow with type  a a1 (b1, b2)- by combining the tuple components with the op arrowexamples with simple list arrows working on strings and XmlTrees  a1 :: a String (XmlTree, XmlTree) a1 = selem "foo" [this >>> mkText] &&& selem "bar" [arr (++"0") >>> mkText] runLA (a1 >>> mergeA (<+>) >>> xshow this) "42" == ["42","420"] runLA (a1 >>> mergeA (+=) >>> xshow this) "42" == ["42420"] see also: ,  and += in class PQ$hxtuseful only for arrows with side effects: perform applies an arrow to the input ignores the result and returns the input example: ( ... >>> perform someTraceArrow >>> ... %hxt#generalization of arrow combinator  definition:  catA = foldl (<+>) none &hxt#generalization of arrow combinator  definition:  seqA = foldl (>>>) this  # !" &$% # !" &$%8822 2!2"2Copyright (C) 2005 Uwe SchmidtMITUwe Schmidt (uwe\@fh-wedel.de) experimentalportable Safe-Inferred3>K'hxtan auxiliary data type for 7)hxt)The interface for arrows as conditionals.Requires list arrows because False is represented as empty list, True as none empty lists.Only * and 6# don't have default implementations*hxtif lifted to arrows+hxt shortcut:  ifP p = ifA (isA p) ,hxt negation:  neg f = ifA f none this -hxt f `when` g  : when the predicate g holds, f is applied, else the identity filter this.hxt shortcut:  f `whenP` p = f `when` (isA p) /hxt f `whenNot` g  : when the predicate g does not hold, f is applied, else the identity filter this0hxtlike .1hxt g `guards` f 6 : when the predicate g holds, f is applied, else none2hxtlike .3hxt shortcut for  f 1 this 4hxt f `containing` g 3 : keep only those results from f for which g holds definition: * f `containing` g = f >>> g `guards` this 5hxt f `notContaining` g ; : keep only those results from f for which g does not hold definition: - f `notContaining` g = f >>> ifA g none this 6hxt f `orElse` g  : directional choice: if f succeeds, the result of f is the result, else g is applied7hxtgeneralisation of 61 for multi way branches like in case expressions.An auxiliary data type ' with an infix constructor (' is used for writing multi way branches example: 4 choiceA [ p1 :-> e1, p2 :-> e2, this :-> default ] 8hxttag a value with Left or Right, if arrow has success, input is tagged with Left, else with Right9hxtsplit a list value with an arrow and returns a pair of lists. This is the arrow version of . The arrow is deterministic. example: ( runLA (spanA (isA (/= '-'))) "abc-def"  gives  [("abc","-def")]  as result:hxt/partition a list of values into a pair of listsThis is the arrow Version of '():987543210/.,+*-6'():987543210/.,+*-6Copyright (C) 2005 Uwe SchmidtMITUwe Schmidt (uwe\@fh-wedel.de) experimental=multi parameter classes and functional depenedencies required Safe-Inferred3>P?;hxt=The interface for accessing and changing the state component.Multi parameter classes and functional dependencies are required.<hxtchange the state of a state arrow by applying a function for computing a new state from the old and the arrow input. Result is the arrow input=hxtaccess the state with a function using the arrow input as data for selecting state components.>hxt+read the complete state, ignore arrow input definition: % getState = accessState (\ s x -> s) ?hxtoverwrite the old state definition: % setState = changeState (\ s x -> x) @hxt4change state (and ignore input) and return new stateconvenience function, usefull for generating e.g. unique identifiers:"example with SLA state list arrows newId :: SLA Int b String newId = nextState (+1) >>> arr (('#':) . show) runSLA 0 (newId <+> newId <+> newId) undefined = ["#1", "#2", "#3"];>?<=@;>?<=@Copyright (C) 2011 Uwe SchmidtMITUwe Schmidt (uwe\@fh-wedel.de) experimentalportable Safe-Inferred3>QAhxtA class of types that can be partially evaluated, but evaluation can be propagated deeper than WHNFBhxt%Default for rwnf is reduction to WHNFChxtDefault for rwnf2 is rwnfACBDEFDEFACBD0Copyright (C) 2011 Uwe SchmidtMITUwe Schmidt (uwe\@fh-wedel.de) experimental non-portable Safe-Inferred3>TWhxt,partial evaluation of an arrow result using RSThere are two arrows with force the partial evaluation. By convention the 2. should be less lazy than the 1.These arrows are sometimes useful for preventing space leaks, especially when parsing complex data structures. In many cases the evaluated AST is more space efficient than the unevaluaded with a lot of closures.\hxt-complete evaluation of an arrow result using RTthis is sometimes useful for preventing space leaks, especially after reading and validation of a document, all DTD stuff is not longer in use and can be recycled by the GC.WYXZ[\\Z[WYXCopyright (C) 2010 Uwe SchmidtMITUwe Schmidt (uwe@fh-wedel.de)stableportable Safe-Inferred3>V^hxtlookup with default value_hxt6lookup with empty list (empty string) as default value`hxttest for existence of a keyahxtadd an entry, remove an existing entry before adding the new one at the top of the list, addEntry is strictbhxt!add a whole list of entries with achxt#delete an entry, delEntry is strictdhxtdelete a list of entries with c]^_`abcd]^_`abcd Copyright (C) 2008 Uwe SchmidtMITUwe Schmidt (uwe\@fh-wedel.de) experimental non-portableNone3>XIfhxtcreation of an Atom from a Stringghxt Insert a String6 into the atom cache and convert the atom back into a String. locically  share == id; holds, but internally equal strings share the same memory.efgefg  Safe-Inferred3>YqhxtSelectors for pairs and 3-tuples: comp1, comp2, comp3, this can be extended to n-tuplesshxtA Selector is a pair of an access function and a modifying function for reading and updating parts of a composite typeyhxtAlias for constructor Smnopqrstvuwxyz{stvuwxyz{qropmn{3 Copyright (C) 2005 Uwe SchmidtMITUwe Schmidt (uwe\@fh-wedel.de) experimentalportable Safe-Inferred3>]hxtThe interface for treeshxttree construction: a new tree is constructed by a node attribute and a list of childrenhxt0leaf construction: leafs don't have any children definition:  mkLeaf n = mkTree n [] hxt"leaf test: list of children empty?hxtinnner node test:  not . isLeaf hxtselect node attributehxtselect childrenhxtedit node attributehxt edit childrenhxtsubstitute node: " setNode n = changeNode (const n) hxtsubstitute children: , setChildren cl = changeChildren (const cl) hxtfold for treeshxtall nodes of a treehxtdepth of a treehxtnumber of nodes in a treehxt%format tree for readable trace outputa  graphical* representation of the tree in text formathxtuhxtThe interface for tree arrows*all functions have default implementationshxtconstruct a leafhxtconstruct an inner nodehxt)select the children of the root of a treehxt*select the node info of the root of a treehxt*select the attribute of the root of a treehxt-substitute the children of the root of a treehxt.substitute the attribute of the root of a treehxt'edit the children of the root of a treehxt(edit the attribute of the root of a treehxtapply an arrow element wise to all children of the root of a tree collect these results and substitute the children with this result example:  processChildren isText 5 deletes all subtrees, for which isText does not hold example: % processChildren (none `when` isCmt) , removes all children, for which isCmt holdshxtsimilar to processChildren, but the new children are computed by processing the whole input tree example:  replaceChildren (deep isText)  selects all subtrees for which isText holds and substitutes the children component of the root node with this listhxt&pronounced "slash", meaning g inside f defined as " f /> g = f >>> getChildren >>> g  example: 2 hasName "html" /> hasName "body" /> hasName "h1" This expression selects all "h1" elements in the "body" element of an "html" element, an expression, that corresponds 1-1 to the XPath selection path "html/body/h1"hxt>pronounced "double slash", meaning g arbitrarily deep inside f defined as ( f //> g = f >>> getChildren >>> deep g  example: $ hasName "html" //> hasName "table" This expression selects all top level "table" elements within an "html" element, an expression. Attention: This does not correspond to the XPath selection path "html//table". The latter on matches all table elements even nested ones, but //>3 gives in many cases the appropriate functionality.hxt+pronounced "outside" meaning f containing g defined as - f >> g) hxtrecursively searches a whole tree for subtrees, for which a predicate holds. The search is performed top down. When a tree is found, this becomes an element of the result list. The tree found is not further examined for any subtress, for which the predicate also could hold. See  for this kind of search. example:  deep isHtmlTable  selects all top level table elements in a document (with an appropriate definition for isHtmlTable) but no tables occuring within a table cell.hxtrecursively searches a whole tree for subrees, for which a predicate holds. The search is performed bottom up. example:  deepest isHtmlTable  selects all innermost table elements in a document but no table elements containing tables. See  and  for other search strategies.hxtrecursively searches a whole tree for subtrees, for which a predicate holds. The search is performed top down. All nodes of the tree are searched, even within the subtrees of trees for which the predicate holds. example:  multi isHtmlTable . selects all table elements, even nested ones.hxtrecursively transforms a whole tree by applying an arrow to all subtrees, this is done bottom up depth first, leaves first, root as last tree example: 1 processBottomUp (getChildren `when` isHtmlFont)  removes all font tags in a HTML document, even nested ones (with an appropriate definition of isHtmlFont)hxt similar to , but recursively transforms a whole tree by applying an arrow to all subtrees with a top down depth first traversal strategie. In many cases  and  give same results.hxtrecursively transforms a whole tree by applying an arrow to all subtrees, but transformation stops when a predicte does not hold for a subtree, leaves are transformed firsthxtrecursively transforms a whole tree by applying an arrow to all subtrees, but transformation stops when a tree is successfully transformed. the transformation is done top down example: : processTopDownUntil (isHtmlTable `guards` tranformTable)  transforms all top level table elements into something else, but inner tables remain unchangedhxtcomputes a list of trees by applying an arrow to the input and inserts this list in front of index i in the list of children example: ! insertChildrenAt 0 (deep isCmt)  selects all subtrees for which isCmt holds and copies theses in front of the existing childrenhxt similar to 9, but the insertion position is searched with a predicatehxtan arrow for inserting a whole subtree with some holes in it (a template) into a document. The holes can be filled with contents from the input.Example insertTreeTemplateTest :: ArrowXml a => a b XmlTree insertTreeTemplateTest = doc >>> insertTreeTemplate template pattern where doc -- the input data = constA "The TitleThe content" >>> xread template -- the output template with 2 holes: xxx and yyy = constA "xxx

yyy

" >>> xread pattern = [ hasText (== "xxx") -- fill the xxx hole with the input contents from element "x/y" :-> ( getChildren >>> hasName "y" >>> deep isText ) , hasText (== "yyy") -- fill the yyy hole with the input contents from element "x/z" :-> ( getChildren >>> hasName "z" >>> getChildren ) ]0computes the XML tree for the following document "The Title

The content

"555 #Copyright (C) 2005-2010 Uwe SchmidtMITUwe Schmidt (uwe\@fh-wedel.de)stableportable Safe-Inferred3>xhxt&shortcut for a sequence of n-ary treeshxtn-ary ordered tree (rose trees)a tree consists of a node and a possible empty list of children. If the list of children is empty, the node is a leaf, else it's an inner node.'NTree implements Eq, Ord, Show and ReadhxtImplementation of Data.Tree.Class interface for rose treeshxt!NTree implements class TaversablehxtNTree implements class FoldablehxtNTree implements class FunctorCopyright (C) 2011 Uwe SchmidtMITUwe Schmidt (uwe\@fh-wedel.de) experimentalportable Safe-Inferred3>|Ahxt9editNTreeBottomUp is a space optimized tree edit functionThe nodes in a tree are visited bottom up. An edit function is applied to all nodes. A Nothing result of the editing function indicates no changes. This is used to share the input tree within the resulting tree.The following law holds: *editNTreeBottomUp (const Nothing) t == [t]In this case the resulting tree does not only represent the same value but it is the same machine value (relative to some evaluations of closures during the tree walkWith a simple fold like editing function the whole tree would be reconstructed in memoryhxt A space optimized map for NTreesSubtrees, that are not changed are reused in the resulting tree See also: editNTreeBottomUpCopyright (C) 2010 Uwe SchmidtMITUwe Schmidt (uwe\@fh-wedel.de) experimentalportable Safe-Inferred3>hxt#Edit operation on navigatable treesThere is only a single navigatable tree implementation for a given tree allowed (see the functional dependencies)hxt;add an ordinary tree in front of the given navigatable treehxt9add an ordinary tree behind of the given navigatable treehxt?drop the direct left sibling tree of the given navigatable treehxtdrop the direct right sibling tree of the given navigatable treehxt)change the tree but remain the navigationhxt/Conversion between trees and navigatable trees,There is only a single navigatable tree implementation for a given tree allowed (see the functional dependencies)hxtconstruct a navigatable treehxtremove navigationhxt#The interface for navigatable treeshxtmove one step towards the roothxt&descend one step to the leftmost childhxtmove to the left neighbourhxtmove to the right neighbourCopyright (C) 2010 Uwe SchmidtMITUwe Schmidt (uwe\@fh-wedel.de) experimentalportable Safe-Inferred3>hxtcollect all trees by moving into one direction, starting tree is includedhxtcollect all trees by moving into one direction, starting tree is not includedhxtXPath axis: parenthxtXPath axis: ancestorhxtXPath axis: ancestor or selfhxtXPath axis: childhxtXPath axis: descendanthxtXPath axis: descendant or selfhxtnot an official XPath axis but useful: reverse descendant or self, used in preceding axishxtXPath axis: following siblinghxtXPath axis: preceeding siblinghxtXPath axis: selfhxtXPath axis: followinghxtXPath axis: precedinghxtmove to the rootCopyright (C) 2010 Uwe SchmidtMITUwe Schmidt (uwe\@fh-wedel.de)stableportable Safe-Inferred3>ghxtOne unzipped step consists of the left siblings, the node info and the right siblingshxt?The list of unzipped nodes from a current tree back to the roothxtZipper for rose treesA zipper consist of the current tree and the branches on the way back to the roothxt6Conversion of a rose tree into a navigatable rose treehxtConversion of a navigatable rose tree into an ordinary rose tree.The context, the parts for moving up to the root are just removed from the tree. So when transforming a navigatable tree by moving around and by changing some nodes, one has to navigate back to the root, else that parts are removed from the resultCopyright (C) 2010 Uwe SchmidtMITUwe Schmidt (uwe\@fh-wedel.de) experimentalportable Safe-Inferred3>hxt)The interface for navigatable tree arrows*all functions have default implementationshxtXPath axis: ancestorhxtXPath axis: ancestor or selfhxtXPath axis: childhxtXPath axis: descendanthxtXPath axis: descendant or selfhxt5not an XPath axis but useful: descendant or followinghxtnot an official XPath axis but useful: reverse descendant or self, used in preceding axishxtXPath axis: following siblinghxtXPath axis: preceeding siblinghxtXPath axis: selfhxtXPath axis: followinghxtXPath axis: precedinghxtmove to the roothxt.Conversion from a tree into a navigatable treehxt8Conversion from a navigatable tree into an ordinary treehxt7apply an operation using navigation to an ordinary tree>> filterAxis (hasNode (== 42))Example: In an XML Tree find the following nodes of a node with attribute id and value 42 descendantAxis >>> filterAxis (hasAttrValue "id" (=="42")) >>> followingAxishxt:Move to the next tree on a given axis. Deterministic arrowExample: Move to the next node in a preorder visit: next child or else next following  moveOn descendantOrFollowingAxishxt1Change the current subtree of a navigatable tree.The arrow for computing the changes should be deterministic. If it fails nothing is changed.hxtSubstitute the current subtree of a navigatable tree by a given treehxtapply an ordinary arrow to the current subtree of a navigatabe tree and add the result trees in front of the current tree.If this arrow is applied to the root, it will fail, because we want a tree as result, not a forest.hxtapply an ordinary arrow to the current subtree of a navigatabe tree and add the result trees behind the current tree.If this arrow is applied to the root, it will fail, because we want a tree as result, not a forest.hxt$addToOneSide does the real work for  and hxt?drop the direct left sibling tree of the given navigatable treeIf this arrow is applied to the root or a leftmost tree, it will fail, because there is nothing to removehxt?drop the direct left sibling tree of the given navigatable treeIf this arrow is applied to the root or a rightmost tree, it will fail, because there is nothing to remove!!Copyright (C) 2010 Uwe SchmidtMITUwe Schmidt (uwe\@fh-wedel.de) experimentalportable Safe-Inferred3>ihxt list arrow combined with a statehxtconversion of state list arrows into arbitray other list arrows.7allows running a state list arrow within another arrow:example: :... >>> fromSLA 0 (... setState ... getState ... ) >>> ...runs a state arrow with initial state 0 (e..g. an Int) within another arrow sequenceCopyright (C) 2005 Uwe SchmidtMITUwe Schmidt (uwe\@fh-wedel.de) experimentalportable Safe-Inferred3>~hxtpure list arrow data typehxtconversion of pure list arrows into other possibly more complex list arrowsCopyright (C) 2011 Uwe SchmidtMITUwe Schmidt (uwe\@fh-wedel.de) experimentalportable Safe-Inferred3>hxtEdit parts of a rose treeThe subtrees to be modified are selected by the first part of the IfThen pairs The modification by the second part Copyright (C) 2005-8 Uwe SchmidtMITUwe Schmidt (uwe\@fh-wedel.de) experimentalportable Safe-Inferred3>\hxt1list arrow combined with a state and the IO monadhxtlift the state of an IOSLA arrow to a state with an additional component.This is uesful, when running predefined IO arrows, e.g. for document input, in a context with a more complex state component.hxtrun an arrow with augmented state in the context of a simple state arrow. An initial value for the new state component is needed.This is useful, when running an arrow with an extra environment component, e.g. for namespace handling in XML.Copyright (C) 2005 Uwe SchmidtMITUwe Schmidt (uwe\@fh-wedel.de) experimentalportable Safe-Inferred3>%hxt!list arrow combined with IO monadUCopyright (C) 2005 Uwe SchmidtMITUwe Schmidt (uwe\@fh-wedel.de) experimentalportable Safe-Inferred3> %$& "! #'():987543210/.,+*-6;@=<>?WXYZ[\ Safe-Inferred3>[hxtthe table with the mapping from file name extensions to mime typesCopyright (C) 2008 Uwe SchmidtMITUwe Schmidt (uwe@fh-wedel.de) experimentalportable Safe-Inferred3>Copyright (C) 2008 Uwe SchmidtMITUwe Schmidt (uwe@fh-wedel.de)stableportable Safe-Inferred3>hxtremove leading and trailing whitespace with standard Haskell predicate isSpacehxtconvert string to uppercase with standard Haskell toUpper functionhxtconvert string to lowercase with standard Haskell toLower functionhxt>find all positions where a string occurs within another stringhxt4find the position of the first occurence of a stringhxt3find the position of the last occurence of a stringhxt8Removes leading / trailing whitespaces and leading zeroshxt2Reduce whitespace sequences to a single whitespacehxt&replace all whitespace chars by blankshxt9Escape all disallowed characters in URI references (see  )http://www.w3.org/TR/xlink/#link-locators)hxtescape XML chars <, >, ", and ampercent by transforming them into character references see also : hxtescape XML chars < and ampercent by transforming them into character references, used for escaping text nodes see also : hxtescape XML chars in attribute values, same as stringEscapeXml, but none blank whitespace is also escaped see also : hxt2convert a string of hexadecimal digits into an Inthxt&convert a string of digits into an Inthxtconvert a string into a hexadecimal string applying charToHexString see also : hxt7convert a char (byte) into a 2-digit hexadecimal string see also : , hxt5convert a none negative Int into a hexadecimal string see also : hxttake all elements of a list which occur more than once. The result does not contain doubles. (doubles . doubles == doubles)hxt9drop all elements from a list which occur more than once.hxtremove duplicates from listhxt(mothers little helpers for to much curryCopyright (C) 2005 Uwe SchmidtMITUwe Schmidt (uwe@fh-wedel.de) experimentalportable Safe-Inferred3>hxtthe predefined namespace uri for xml: "http://www.w3.org/XML/1998/namespace"hxtthe predefined namespace uri for xmlns: "http://www.w3.org/2000/xmlns/"hxtRelax NG namespaceCopyright (C) 2011 Uwe SchmidtMITUwe Schmidt (uwe@fh-wedel.de)stableportableNone3>dhxt2Namespace support for element and attribute names.A qualified name consists of a name prefix, a local name and a namespace uri. All modules, which are not namespace aware, use only the  component. When dealing with namespaces, the document tree must be processed by )V to split names of structure "prefix:localPart" and label the name with the apropriate namespace urihxtType for the namespace association list, used when propagating namespaces by modifying the  values in a treehxtXML names are represented by Strings, but these strings do not mix up with normal strings. Names are always reduced to normal form, and they are stored internally in a name cache for sharing equal names by the same data structurehxtset name prefixhxtset local parthxtset name prefixhxtbuilds the full name "prefix:localPart", if prefix is not null, else the local part is the resulthxt6functional list version of qualifiedName used in xshowhxtbuilds the "universal" name, that is the namespace uri surrounded with "{" and "}" followed by the local part (specialisation of )hxtbuilds an "universal" uri, that is the namespace uri followed by the local part. This is usefull for RDF applications, where the subject, predicate and object often are concatenated from namespace uri and local part (specialisation of )hxtbuilds a string from the namespace uri and the local part. If the namespace uri is empty, the local part is returned, else namespace uri and local part are combined with the combining function given by the first parameterhxtconstructs a simple name, with prefix and localPart but without a namespace uri. see also , hxtconstructs a simple, namespace unaware name. If the name is in prefix:localpart form and the prefix is not empty the name is split internally into a prefix and a local part.hxt*constructs a complete qualified name with ,  and . This function can be used to build not wellformed prefix:localpart names. The XPath module uses wildcard names like xxx:*. These must be build with  and not with mkName.hxt old name for hxtconstructs a simple, namespace aware name, with prefix:localPart as first parameter, namspace uri as second. see also , hxtEquivalent QNames are defined as follows: The URIs are normalized before comparison. Comparison is done with  and hxt.Comparison of normalized namespace URIs using hxt*Sometimes a weaker equality relation than  equalQName is appropriate, e.g no case significance in names, ... a name normalization function can be applied to the strings before comparing. Called by  equalQName and hxtNormalization of URIs: Normalization is done by conversion into lowercase letters. A trailing "/" is ignoredhxtCompute the name prefix and the namespace uri for a qualified name.This function does not test whether the name is a wellformed qualified name. see Namespaces in XML Rule [6] to [8]. Error checking is done with separate functions, see  and  for error checking.hxt3test for wellformed NCName, rule [4] XML Namespaceshxttest for wellformed QName, rule [6] XML Namespaces predicate is used in filter valdateNamespaces.hxttest for wellformed QName values. A QName is wellformed, if the local part is a NCName, the namePrefix, if not empty, is also a NCName. predicate is used in filter valdateNamespaces.hxttest whether an attribute name is a namesapce declaration name. If this is not the case True is the result, else the name must be a well formed namespace name: All namespace prefixes starting with "xml" are reserved for XML related definitions. predicate is used in filter valdateNamespaces.hxt+test for a namespace name to be well formedhxt=test whether a name is a namespace declaration attribute namehxtpredicate is used in filter valdateNamespaces.hxtTwo QNames are equal if (1. case) namespaces are both empty and the qualified names (prefix:localpart) are the same or (2. case) namespaces are set and namespaces and local parts are equal..#Copyright (C) 2008-2010 Uwe SchmidtMITUwe Schmidt (uwe@fh-wedel.de)stableportableNone3>ƍ&hxt=data type for representing a set of nodes as a tree structurethis structure is e.g. used to repesent the result of an XPath query such that the selected nodes can be processed or selected later in processing a document treehxtis this node part of the set ?hxtthe set of attribute nodeshxt=the set of child nodes, a list of pairs of index and node sethxtAttribute list7used for storing option lists and features of DTD partshxt4Binary large object implemented as a lazy bytestringhxtRepresents a DTD elementhxt9attr: name, system, public, XDTD elems as childrenhxtattr: name, kindname: element name4kind: "EMPTY" | "ANY" | "#PCDATA" | children | mixedhxtelement contentattr: kind, modifiermodifier: "" | "?" | "*" | "+"kind: seq | choicehxt$attributes: name - name of elementvalue - name of attributetype: "CDATA" | "ID" | "IDREF" | "IDREFS" | "ENTITY" | "ENTITIES" |/"NMTOKEN" | "NMTOKENS" |"NOTATION" | "ENUMTYPE"kind: "REQUIRED\" | \"IMPLIED" | "DEFAULT"hxtfor entity declarationshxt!for parameter entity declarationshxt for notationshxt,for INCLUDEs, IGNOREs and peRefs: attr: typetype = INCLUDE, IGNORE or %...;hxt attr: namefor lists of names in notation types or nmtokens in enumeration typeshxt'for Parameter Entity References in DTDshxtRepresents elementshxt:ordinary text (leaf)hxt:text represented more space efficient as bytestring (leaf)hxt:character reference (leaf)hxt:entity reference (leaf)hxt:comment (leaf)hxt:CDATA section (leaf)hxtProcessing Instr with qualified name (leaf) with list of attributes. If tag name is xml, attributes are "version", "encoding", "standalone", else attribute list is empty, content is a text child nodehxttag with qualified name and list of attributes (inner node or leaf)hxt4DTD element with assoc list for dtd element featureshxtattribute with qualified name, the attribute value is stored in childrenhxt!error message with level and texthxt-List of navigatable rose trees with XML nodeshxt$Navigatable rose tree with XML nodeshxt!List of rose trees with XML nodeshxt Rose tree with XML nodes (XNode)hxt!Evaluate an assoc list of stringshxtno error, everything is okhxt$Error level for XError, type warninghxt"Error level for XError, type errorhxt(Error level for XError, type fatal error]^_`abcd*WCopyright (C) 2008 Uwe SchmidtMITUwe Schmidt (uwe@fh-wedel.de)stableportableNone3>]^_`abcdCopyright (C) 2010 Uwe SchmidtMITUwe Schmidt (uwe@fh-wedel.de)stableportableNone3>Ϛhxtpredefined system state data type with all components for the system functions, like trace, error handling, ...hxt8The arrow for stateful arrows with no user defined statehxt"The arrow type for stateful arrowshxtstate datatype consists of a system state and a user state the user state is not fixedhxt'read the user defined part of the statehxt)change the user defined part of the statehxt&set the user defined part of the statehxtextend user stateRun an arrow with an extended user state component, The old component is stored together with a new one in a pair, the arrow is executed with this extended state, and the augmented state component is removed form the state when the arrow has finished its executionhxtchange the type of user stateThis conversion is useful, when running a state arrow with another structure of the user state, e.g. with () when executing some IO arrowshxt;store a string in global state under a given attribute namehxt>remove an entry in global state, arrow input remains unchangedhxt)read an attribute value from global statehxt%read all attributes from global statehxt"store an int value in global statehxt#read an int value from global state getSysAttrInt 0 myIntAttrstuvwz{stuvwz{Copyright (C) 2010 Uwe SchmidtMITUwe Schmidt (uwe@fh-wedel.de)stableportableNone3>Fhxtset the table mapping of file extensions to mime types in the system stateDefault table is defined in XY. This table is used when reading loacl files, (file: protocol) to determine the mime typehxtset the table mapping of file extensions to mime types by an external config file/The config file must follow the conventions of etcmime.types on a debian linux system, that means all empty lines and all lines starting with a # are ignored. The other lines must consist of a mime type followed by a possible empty list of extensions. The list of extenstions and mime types overwrites the default list in the system state of the IOStateArrowhxtread the system mimetype table Copyright (C) 2008 Uwe SchmidtMITUwe Schmidt (uwe@fh-wedel.de)stableportableNone3>hxt(weak normalform versions of constructors! Copyright (C) 2008-9 Uwe SchmidtMITUwe Schmidt (uwe@fh-wedel.de)stableportableNone3>ڊhxt%convert a list of trees into a string see also : xmlTreesToText for filter version, 3Z for the inverse operationhxt=convert an XML tree into a binary large object (a bytestring)hxt$convert a list of trees into a blob.Apply a quoting function for XML quoting of content, a 2. quoting funtion for attribute values and an encoding function after tree conversion"Copyright (C) 2008 Uwe SchmidtMITUwe Schmidt (uwe@fh-wedel.de) experimentalportableNone3>_hxtcheck whether a sequence of XmlTrees match an Xml regular expressionThe arrow for .The expession is build up from simple arrows acting as predicate (<) for an XmlTree and of the usual cobinators for sequence (), repetition ( , mkRep', ) and choice (, )hxt9split the sequence of trees computed by the filter a intoThe arrow for .a first part matching the regex and a rest, if a prefix of the input sequence does not match the regex, the arrow fails else the pair containing the result lists is returnedhxtscan the input sequence with a regex and give the result as a list of lists of trees back the regex must at least match one input tree, so the empty sequence should not match the regexThe arrow for .hxtmatch a sequence of XML trees with a regular expression over treesIf the input matches, the result is Nothing, else Just an error message is returnedhxtsplit a sequence of XML trees into a pair of a a matching prefix and a rest3If there is no matching prefix, Nothing is returnedhxtscan a sequence of XML trees and split it into parts matching the given regexIf the parts cannot be split because of a missing match, or because of the empty sequence as match, Nothing is returned#Copyright (C) 2008 Uwe SchmidtMITUwe Schmidt (uwe@fh-wedel.de)stableportableNone3>@$Copyright (C) 2011 Uwe SchmidtMITUwe Schmidt (uwe@fh-wedel.de) experimentalportableNone3>hxtDocument Type Definition arrowsThese are separated, because they are not needed for document processing, only when processing the DTD, e.g. for generating access funtions for the toolbox from a DTD (se example DTDtoHaskell in the examples directory)hxtArrows for processing [sThese arrows can be grouped into predicates, selectors, constructors, and transformers. All predicates (tests) act like \ for failure and ]- for success. A logical and can be formed by  a1 >>> a2 , a locical or by  a1 <+> a2 .Selector arrows will fail, when applied to wrong input, e.g. selecting the text of a node with , will fail when applied to a none text node.Edit arrows will remain the input unchanged, when applied to wrong argument, e.g. editing the content of a text node with  applied to an element node will return the unchanged element node.hxttest for text nodeshxt,test for char reference, used during parsinghxt.test for entity reference, used during parsinghxttest for commenthxt+test for CDATA section, used during parsinghxttest for processing instructionhxt*test for processing instruction hxttest for elementhxt&test for DTD part, used during parsinghxttest for attribute treehxttest for error messagehxt*test for root node (element with name "/")hxt:test for text nodes with text, for which a predicate holds example: hasText (all (`elem` " \t\n"))2 check for text nodes with only whitespace contenthxt)test for text nodes with only white spaceimplemented with hasTesthxttest whether a node (element, attribute, pi) has a name with a special propertyhxttest whether a node (element, attribute, pi) has a specific qualified name useful only after namespace propagationhxttest whether a node has a specific name (prefix:localPart or localPart), generally useful, even without namespace handlinghxttest whether a node has a specific name as local part, useful only after namespace propagationhxttest whether a node has a specific name prefix, useful only after namespace propagationhxttest whether a node has a specific namespace URI useful only after namespace propagationhxttest whether an element node has an attribute node with a specific namehxttest whether an element node has an attribute node with a specific qualified namehxttest whether an element node has an attribute with a specific valuehxttest whether an element node has an attribute with a qualified name and a specific valuehxttext node construction arrowhxtblob node construction arrowhxt=char reference construction arrow, useful for document outputhxt?entity reference construction arrow, useful for document outputhxt5comment node construction, useful for document outputhxt.CDATA construction, useful for document outputhxt/error node construction, useful only internallyhxtelement construction: | the attributes and the content of the element are computed by applying arrows to the inputhxtattribute node construction: | the attribute value is computed by applying an arrow to the inputhxtprocessing instruction construction: | the content of the processing instruction is computed by applying an arrow to the inputhxtconvenient arrow for element construction, more comfortable variant of example for simplifying  : 4mkElement qn (a1 <+> ... <+> ai) (c1 <+> ... <+> cj)equals "mkqelem qn [a1,...,ai] [c1,...,cj]hxtconvenient arrow for element construction with strings instead of qualified names as element names, see also  and hxtconvenient arrow for element construction with attributes but without content, simple variant of  and hxtconvenient arrow for simple element construction without attributes, simple variant of  and hxtconvenient arrow for construction of empty elements without attributes, simple variant of  and hxtconstruction of an element node with name "/" for document rootshxt alias for hxt?convenient arrow for attribute construction, simple variant of hxtconstant arrow for text nodeshxtconstant arrow for blob nodeshxt'constant arrow for char reference nodeshxt)constant arrow for entity reference nodeshxtconstant arrow for commenthxtconstant arrow for warninghxtconstant arrow for errorshxtconstant arrow for fatal errorshxt7constant arrow for simple processing instructions, see hxtconstant arrow for attribute nodes, attribute name is a qualified name and value is a text, | see also , , hxtconstant arrow for attribute nodes, attribute name and value are | given by parameters, see hxtselect the text of a text nodehxt$select the value of a char referencehxt*select the name of a entity reference nodehxt$select the comment of a comment nodehxt"select the content of a CDATA nodehxt+select the name of a processing instructionhxt.select the content of a processing instructionhxt"select the name of an element nodehxt,select the attribute list of an element nodehxt!select the DTD type of a DTD nodehxt'select the DTD attributes of a DTD nodehxtselect the name of an attributehxtselect the error level (c_warn, c_err, c_fatal) from an error nodehxt+select the error message from an error nodehxt:select the qualified name from an element, attribute or pihxtselect the prefix:localPart or localPart from an element, attribute or pihxt7select the univeral name ({namespace URI} ++ localPart)hxt5select the univeral name (namespace URI ++ localPart)hxtselect the local parthxtselect the name prefixhxtselect the namespace URIhxtselect the value of an attribute of an element node, always succeeds with empty string as default value ""hxtlike +, but fails if the attribute does not existhxtlike , but select the value of an attribute given by a qualified name, always succeeds with empty string as default value ""hxtlike ', but fails if attribute does not existhxtedit the string of a text nodehxtedit the blob of a blob nodehxt)edit the comment string of a comment nodehxt(edit an element-, attribute- or pi- namehxtedit an element namehxtedit an attribute namehxtedit a pi namehxtedit an attribute valuehxt)edit an attribute list of an element nodehxt(replace an element, attribute or pi namehxtreplace an element namehxtreplace an attribute namehxtreplace an element namehxt+replace an atribute list of an element nodehxt&add a list of attributes to an elementhxtadd (or replace) an attributehxtremove an attributehxt)remove an attribute with a qualified namehxt7process the attributes of an element node with an arrowhxtprocess a whole tree inclusive attribute list of element nodes see also: hxt9convenient op for adding attributes or children to a nodeusage:  tf += cf the tf; arrow computes an element node, and all trees computed by cf are added to this node, if a tree is an attribute, it is inserted in the attribute list else it is appended to the content list.;attention: do not build long content list this way because  is implemented by ++ examples: eelem "a" += sattr "href" "page.html" += sattr "name" "here" += txt "look here"is the same as mkelem [ sattr "href" "page.html" , sattr "name" "here" ] [ txt "look here" ]and results in the XML fragment: look hereadvantage of the  operator is, that attributes and content can be added any time step by step. if tf computes a whole list of trees, e.g. a list of "td" or "tr" elements, the attributes or content is added to all trees. useful for adding "class" or "style" attributes to table elements.hxtapply an arrow to the input and convert the resulting XML trees into a string representationhxtapply an arrow to the input and convert the resulting XML trees into a string representation7%Copyright (C) 2010 Uwe SchmidtMITUwe Schmidt (uwe@fh-wedel.de)stableportableNone3> hxtreset global error variablehxtset global error variablehxt read current global error statushxt=raise the global error status level to that of the input treehxtset the error message handler and the flag for collecting the errorshxt*error message handler for output to stderrhxt9the default error message handler: error output to stderrhxt+error message handler for collecting errorshxt9error message handler for output to stderr and collectinghxt)error message handler for ignoring errorshxtif error messages are collected by the error handler for processing these messages by the calling application, this arrow reads the stored messages and clears the error message storehxt7filter error messages from input trees and issue errorshxtgenerate a warnig messagehxtgenerate an error messagehxt7generate a fatal error message, e.g. document not foundhxtDefault exception handler: issue a fatal error message and fail.! hxtwithTrace level- : system option, set the trace level, (0..4)hxtwithSysAttr key value4 : store an arbitrary key value pair in system statehxt'Specify the set of accepted mime types.All contents of documents for which the mime type is not found in this list are discarded.hxt,<,",',& where neccessary, add XML processing instruction and encode document with respect to hxtWrite XHTML: quote all special XML chars, use HTML entity refs or char refs for none ASCII charshxtWrite XML: quote only special XML chars, don't substitute chars by HTML entities, and don't generate empty elements for HTML elements, which may contain any contents, e.g.  scriptsrc=... /script instead of  script src=... /hxt+suppreses all char and entitiy substitutionhxtConfigure compression and decompression for binary serialization/deserialization. First component is the compression function applied after serialization, second the decompression applied before deserialization.hxt/Strict input for deserialization of binary data**'Copyright (C) 2010 Uwe SchmidtMITUwe Schmidt (uwe@fh-wedel.de)stableportableNone3>%0hxt%commonly useful options for XML input5can be used for option definition with haskell getoptdefines options:  ,  ,  a_use_curl, a_do_not_use_curl, a_options_curl, , , ,  ,  , , ,  ,  , , , ,hxt&commonly useful options for XML outputdefines options: , ,   and othershxtcommonly useful optionsdefines options:  , hxtdefines  optionhxtdebug output options hxt