On Monday 13 October 2003 11:54 am, Jose Morais wrote:
> Hi,
>
>       I am trying to something like
>
> f1 :: Int -> Int
> f1 x = f2 x
>
> f2 :: Int -> Int
> f2 x = 2 * x
>
>
>       but before f2 returns its result I'd like it to print something like
> "The initial value is " ++ show x.
>

f1 :: Int -> IO Int
f1 x = f2 x

f2 :: Int -> IO Int
f2 x = do
            putStrLn $ "The initial value is " ++ show x
            return (2 * x)

The previously mentioned trace method is prefered for debugging because 
with this, one is now in the IO monad.

Shawn
_______________________________________________
Haskell-Cafe mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to