While using The Glorious Glasgow Haskell Compilation System, version 8.0.2, I'm trying to add trace information to the following script:
import Debug.Trace
init :: Show a => [a] -> [a]
init l@(x:xs) | trace
(
if (length l) < 2
then ( "\n\tinit [" ++ show x ++ "] = []" )
else ( "\n\tinit " ++ show l ++ " = " ++ show x ++ " : (init " ++ show xs ++ ")" )
) False = undefined
init [_] = []
init (x:xs) = x : (Main.init xs)
However, the output of the trace is interleaved with the output of evaluating the expression Main.init [2,3,5,7]
, as shown below:
C:\>ghci my_script.hs
GHCi, version 8.0.2: http://www.haskell.org/ghc/ :? for help
[1 of 1] Compiling Main ( my_script.hs, interpreted )
Ok, modules loaded: Main.
*Main> Main.init [2,3,5,7]
init [2,3,5,7] = 2 : (init [3,5,7])
[2
init [3,5,7] = 3 : (init [5,7])
,3
init [5,7] = 5 : (init [7])
,5
init [7] = []
]
*Main> :quit
Leaving GHCi.
How would one cause the following four lines to be omitted from the output?
[2
,3
,5
]
I have already tried using a couple of different variations of :set -fno-print-bind-result
as shown at https://downloads.haskell.org/~ghc/6.8.1/docs/html/users_guide/interactive-evaluation.html, but to no avail.