Re: [Haskell-cafe] trace function

2006-07-20 Thread Malcolm Wallace
Alexander Vodomerov <[EMAIL PROTECTED]> wrote: > main = do > putStrLn "xxx" > return (trace "yyy" ()) > putStrLn "zzz" > > only xxx and zzz is displayed. yyy is missing. This is because you never demanded the value of (trace "yyy" ()), so it was never computed. The joys of laziness! To f

Re: [Haskell-cafe] trace function

2006-07-20 Thread Neil Mitchell
Hi, Either one of these will work: main = do putStrLn "xxx" x <- return (trace "yyy" ()) x `seq` putStrLn "zzz" main = do putStrLn "xxx" trace "yyy" (return ()) putStrLn "zzz" This works fine, the problem is that trace is defined to output the first parameter before returning the second. In t

[Haskell-cafe] trace function

2006-07-20 Thread tpledger
Alexander Vodomerov wrote: > import Debug.Trace > > main = do > putStrLn "xxx" > return (trace "yyy" ()) > putStrLn "zzz" > > only xxx and zzz is displayed. yyy is missing. > Why trace is not working? Nothing uses the value of (trace "yyy" ()), so it is never evaluated. Try this instead, wh

[Haskell-cafe] trace function

2006-07-20 Thread Alexander Vodomerov
Hello! The function trace is supposed to write debug messages to console. However, when I trying to run the following program import Debug.Trace main = do putStrLn "xxx" return (trace "yyy" ()) putStrLn "zzz" only xxx and zzz is displayed. yyy is missing. Why trace is not working? PS.