Question

I've seen on HXT library that there is two functions for texting message on the prompt of my terminal which are :

withTraceLevel

and

traceMsg

The first function "withTraceLevel" works like a charm, but the second function doesn't work on my code, am i missing something ?

Example of my code :

procIntersection = proc it -> do
            set1 <- (getChildren >>> withTraceLevel 5 traceTree >>> traceMsg 1 "*********************************") -< it
            returnA -< Intersection { setI1 = OWLNothing, setI2 = OWLNothing{--set2--} }

Output :

content of:
============


---XTag "rdf:Description"

   |   "rdf:about"="http://www.xfront.com/owl/ontologies/camera/#Body"

content of:

============


---XTag "owl:Restriction"

    |

    +---XTag "owl:onProperty"
    |   |   "rdf:resource"="http://www.xfront.com/owl/ontologies/camera/#shutter-speed"
    |
    +---XTag "owl:cardinality"
      |   "rdf:datatype"="http://www.w3.org/2001/XMLSchema#nonNegativeInteger"
      |
      +---XText "0"




content of:

============


---XTag "rdf:Description"

 |   "rdf:about"="http://www.xfront.com/owl/ontologies/camera/#Camera"




content of:

============


---XTag "owl:Restriction"

   |

   +---XTag "owl:onProperty"

   |   |   "rdf:resource"="http://www.xfront.com/owl/ontologies/camera/#viewFinder"

   |

   +---XTag "owl:hasValue"

       |   "rdf:resource"="http://www.xfront.com/owl/ontologies/camera/#ThroughTheLens"

Normally, after the second "content of" it should be a line with : *********** But that line isn't appearing there !

Was it helpful?

Solution

withTraceLevel sets only the trace level for the arrow you give as its second parameter.

In your code below, withTraceLevel enables trace and sets the level during traceTree execution only, not the rest

withTraceLevel 5 traceTree >>> traceMsg 1 "bla bla"

try this instead

withTraceLevel 5 (traceTree >>> traceMsg 1 "bla bla")

See what happens in the interpreter:

$ ghci
Prelude> :m +Text.XML.HXT.Core Text.XML.HXT.Arrow.XmlState.TraceHandling
Prelude ...> runX $ withTraceLevel 2 $ traceMsg 1 "hi!"
Loading package array-0.4.0.1 ... linking ... done.
Loading ...
-- (1) hi!
[NTree (XTag "/" []) []]
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top