
Welcome to issue 280 of the HWN, an issue covering crowd-sourced bits of information about Haskell from around the web. This issue covers the week of September 8 to 14, 2013. Quotes of the Week * haasn: edwardk uses things in anger. shachaf uses them with disappointment :( * shachaf: Are you reading Mac Lane now? Saizan: yeah, it's not so bad if you skip the examples Top Reddit Stories * For my 17th birthday, my best friend got me "The most obscure programming book I could find" as a joke. I know what language I am learning next! Domain: i.imgur.com, Score: 163, Comments: 67 On Reddit: [1] http://goo.gl/0SyN5l Original: [2] http://goo.gl/oqGBzL * pipes-4.0: Simpler types and API Domain: haskellforall.com, Score: 95, Comments: 36 On Reddit: [3] http://goo.gl/ciVnq5 Original: [4] http://goo.gl/g9oq3i * Hackage 2 now available for beta testing -- switchover in a few weeks Domain: beta.hackage.haskell.org, Score: 91, Comments: 17 On Reddit: [5] http://goo.gl/aIhL67 Original: [6] http://goo.gl/zfprr9 * Cartesian Closed Comic #22: Cabal 1.18 Domain: ro-che.info, Score: 90, Comments: 3 On Reddit: [7] http://goo.gl/tVUUFG Original: [8] http://goo.gl/O0BR6c * Parallel and Incremental CRCs by Edward Kmett Domain: fpcomplete.com, Score: 58, Comments: 7 On Reddit: [9] http://goo.gl/YAChJl Original: [10] http://goo.gl/WnMsbY * Conquering Folds by Edward Kmett Domain: fpcomplete.com, Score: 47, Comments: 42 On Reddit: [11] http://goo.gl/reAjgu Original: [12] http://goo.gl/kHsSye * Conal Elliot: From Haskell to hardware via cartesian closed categories Domain: conal.net, Score: 47, Comments: 3 On Reddit: [13] http://goo.gl/VCwp7Y Original: [14] http://goo.gl/NO1sbs * FP Complete to release a personal edition of their online IDE Domain: fpcomplete.com, Score: 39, Comments: 38 On Reddit: [15] http://goo.gl/QOMy5Y Original: [16] http://goo.gl/XBE7zT * Quark : A Web Browser with a Formally Verified Kernel Domain: goto.ucsd.edu, Score: 36, Comments: 6 On Reddit: [17] http://goo.gl/RDZMY0 Original: [18] http://goo.gl/rgBcki * My first Haskell program - FNIStash - a utility for Torchlight 2 using threepenny for the GUI Domain: fluffynukeit.com, Score: 36, Comments: 19 On Reddit: [19] http://goo.gl/cK2N8v Original: [20] http://goo.gl/XOMTgQ * Conal Elliott: Overloading lambda Domain: conal.net, Score: 34, Comments: 4 On Reddit: [21] http://goo.gl/fQTt1P Original: [22] http://goo.gl/oPSQ3R * Cost semantics for STG in modern GHC Domain: blog.ezyang.com, Score: 31, Comments: 5 On Reddit: [23] http://goo.gl/mIQQxm Original: [24] http://goo.gl/5Sa49T * 0install - Python vs. OCaml vs. Haskell Domain: roscidus.com, Score: 31, Comments: 23 On Reddit: [25] http://goo.gl/htCf1x Original: [26] http://goo.gl/zhrVp0 * LogicGrowsOnTrees: a parallel implementation of logic programming using distributed tree exploration Domain: github.com, Score: 31, Comments: 9 On Reddit: [27] http://goo.gl/zp5lou Original: [28] http://goo.gl/5BgYh2 * RSS reader made by Haskell running on mbed platform (RAM size 64kB, using Ajhc Haskell compiler). Domain: youtube.com, Score: 30, Comments: 5 On Reddit: [29] http://goo.gl/n0Gkan Original: [30] http://goo.gl/cwL4vP * Conal Elliott: Optimizing CCCs Domain: conal.net, Score: 30, Comments: 12 On Reddit: [31] http://goo.gl/HVv8dr Original: [32] http://goo.gl/MCn0sO * Snap (and Heist) 0.13 released Domain: snapframework.com, Score: 29, Comments: 7 On Reddit: [33] http://goo.gl/zW5Sdn Original: [34] http://goo.gl/1wSLeJ * ANN: threepenny-gui-0.3 – GUI framework that uses the web browser as a display – now with FRP built-in Domain: apfelmus.nfshost.com, Score: 28, Comments: 8 On Reddit: [35] http://goo.gl/RUDrKD Original: [36] http://goo.gl/WZMeZN Top StackOverflow Questions * In Haskell, where does the range ['a'..] stop? votes: 20, answers: 2 Read on SO: [37] http://goo.gl/Oms7lr * Why were Haskell 98's standard classes made inferior to Haskell 1.3's? votes: 18, answers: 1 Read on SO: [38] http://goo.gl/WxvdL2 * 27 different Bool to Bool values in Haskell votes: 14, answers: 1 Read on SO: [39] http://goo.gl/1PcD1g * How to reconstruct Haskell expression from type votes: 10, answers: 1 Read on SO: [40] http://goo.gl/Qx06kz * Can links to anchors in haddock be labeled? votes: 8, answers: 0 Read on SO: [41] http://goo.gl/5deOMM * How to convert between ByteString and Storable Vector? votes: 7, answers: 1 Read on SO: [42] http://goo.gl/zBVVzI * Why is not GHC optimizing for constants? votes: 7, answers: 2 Read on SO: [43] http://goo.gl/sfo64S * newtype around ST causes type error votes: 7, answers: 1 Read on SO: [44] http://goo.gl/CwXaJp * GHC does not generate a binary despite no errors shown votes: 6, answers: 1 Read on SO: [45] http://goo.gl/PAv1oQ Until next time, [46]+Daniel Santa Cruz References

Hello Cafe, I have this HTML structure: ... <table> ... <tr> <th>Caption</th> <td> <a href="...">Want this</a> <a href="...">And this</a> </td> </tr> <tr> <th>Another caption</th> <td> .... <tr> <th>Yet another caption</th> ... </table> ... I'd like to extract A texts from row with header "Caption", and have come up with this runX $ doc >>> (deep (hasName "tr") -- filter only TRs >>> withTraceLevel 5 traceTree -- shows correct TR `when` deep ( hasName "th" >>> -- filter THs with specified text getChildren >>> hasText (=="Caption") ) -- inner deep >>> getChildren >>> hasName "td" -- shouldn't here be only one TR? >>> getChildren ) >>> getName &&& (getChildren >>> getText) -- list has TDs from all three TRs Tried with `guards` but getting the same result. I know there are other packages that might solve this in another way, but I'd like to understand what is going on here. br, vlatko

On 13-09-21 05:13 AM, Vlatko Basic wrote:
I'd like to extract A texts from row with header "Caption", and have come up with this
runX $ doc >>> (deep (hasName "tr") -- filter only TRs >>> withTraceLevel 5 traceTree -- shows correct TR `when` deep ( hasName "th" >>> -- filter THs with specified text getChildren >>> hasText (=="Caption") ) -- inner deep >>> getChildren >>> hasName "td" -- shouldn't here be only one TR? >>> getChildren ) >>> getName &&& (getChildren >>> getText) -- list has TDs from all three TRs
Operator precedences:
infixr 1 `when` infixl 9 (default)
Therefore, this expression redundantly parenthesized and systematically indented to ensure that you are on the same page with the computer is: runX $ doc >>> ( deep (hasName "tr") >>> -- begin{conditionally prints but otherwise is arr id} ( withTraceLevel 5 traceTree `when` deep ( hasName "th" >>> getChildren >>> hasText (=="Caption") ) -- inner deep ) -- end{conditionally prints but otherwise is arr id} >>> getChildren >>> hasName "td" >>> getChildren ) >>> ( getName &&& (getChildren >>> getText) ) The condition on <th>Caption</th> ends up controlling trace messages only; it is not used to limit real processing. "when" doesn't help even when used correctly: it doesn't ban data. "guards" and "containing" ban data, but you have to put them at the right place, i.e., parenthesize correctly. runX $ doc >>> ( deep ( hasName "tr" `containing` deep ( hasName "th" >>> getChildren >>> hasText (=="Caption") ) ) >>> getChildren >>> hasName "td" >>> getChildren ) >>> ( getName &&& (getChildren >>> getText) )

Hi Albert,
thanks for your answer. It helped in some other issues I have.
I did experiment with parenthesis, but obviously not in the right place.
I found the filterA arrow to do the thing I want, like this:
getRowWithHeading caption =
filterA (deep (hasName "th" /> hasText (==caption) )) />
hasName "td" >>>
getChildren
I like to ask you if you might know the answer to the following:
In a structure
+---XTag "a"
| +---XText "A text 1"
|
+---XText "Plain text 1"
|
+---XTag "a"
| +---XText "A text 2"
|
+---XText "Plain text 2"
...
I must combine "A text 1" with "Plain text 1", etc., but they are in sequence on
the same level.
Is it possible, in a simple way, to do it in a single arrow flow?
(Or only outside the arrow by pairing the list items?)
Something like:
hasName "a" /> getText &&& (getNextItem??? >>> getText)
I assume not, but I'm still new to Haskell and would like to check.
br,
vlatko
-------- Original Message --------
Subject: Re: [Haskell-cafe] Problem with HXT `when`
From: Albert Y. C. Lai
On 13-09-21 05:13 AM, Vlatko Basic wrote:
I'd like to extract A texts from row with header "Caption", and have come up with this
runX $ doc >>> (deep (hasName "tr") -- filter only TRs >>> withTraceLevel 5 traceTree -- shows correct TR `when` deep ( hasName "th" >>> -- filter THs with specified text getChildren >>> hasText (=="Caption") ) -- inner deep >>> getChildren >>> hasName "td" -- shouldn't here be only one TR? >>> getChildren ) >>> getName &&& (getChildren >>> getText) -- list has TDs from all three TRs
Operator precedences:
infixr 1 `when` infixl 9 (default)
Therefore, this expression redundantly parenthesized and systematically indented to ensure that you are on the same page with the computer is:
runX $ doc >>> ( deep (hasName "tr") >>> -- begin{conditionally prints but otherwise is arr id} ( withTraceLevel 5 traceTree `when` deep ( hasName "th" >>> getChildren >>> hasText (=="Caption") ) -- inner deep ) -- end{conditionally prints but otherwise is arr id} >>> getChildren >>> hasName "td" >>> getChildren ) >>> ( getName &&& (getChildren >>> getText) )
The condition on <th>Caption</th> ends up controlling trace messages only; it is not used to limit real processing.
"when" doesn't help even when used correctly: it doesn't ban data. "guards" and "containing" ban data, but you have to put them at the right place, i.e., parenthesize correctly.
runX $ doc >>> ( deep ( hasName "tr" `containing` deep ( hasName "th" >>> getChildren >>> hasText (=="Caption") ) ) >>> getChildren >>> hasName "td" >>> getChildren ) >>> ( getName &&& (getChildren >>> getText) )
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
participants (3)
-
Albert Y. C. Lai
-
Daniel Santa Cruz
-
Vlatko Basic