[Haskell-cafe] Tracing a list comprehension

Brandon S. Allbery KF8NH allbery at ece.cmu.edu
Thu Jan 18 17:04:50 EST 2007


On Jan 18, 2007, at 17:00 , Philippe de Rochambeau wrote:

> concat1 :: [[a]] -> [a]
> concat1 xss = [ x | xs <- xss, x <- xs ]
>
> I would like to see what gets stored in xs.

Offhand:

 > import Debug.Trace
 >
 > concat1 :: Show a => [[a]] -> [a]
 > concat1 xss = [ x | xs <- xss, x <- trace (show xs) xs ]

(The Show qualification is kinda unfortunate.)

-- 
brandon s. allbery    [linux,solaris,freebsd,perl]     allbery at kf8nh.com
system administrator [openafs,heimdal,too many hats] allbery at ece.cmu.edu
electrical and computer engineering, carnegie mellon university    KF8NH





More information about the Haskell-Cafe mailing list