Keith Wansbrough <[EMAIL PROTECTED]> writes:
>> Hal Daume III <[EMAIL PROTECTED]> writes:
>>
f1 :: Int -> Int
f1 x
| trace ("The initial value is " ++ show x) False = undefined
| otherwise = f2 x
>>>
>>> In general, the 'trace ... False = undefined' thing is
>>> quite usef
In addition to what Keith said, it's also guarenteed that the trace is
evaluated as soon as the function is entered.
- Hal
On Tue, 2003-10-14 at 02:36, Ferenc Wagner wrote:
> Hal Daume III <[EMAIL PROTECTED]> writes:
>
> >> f1 :: Int -> Int
> >> f1 x
> >> | trace ("The initial value is " ++
> Hal Daume III <[EMAIL PROTECTED]> writes:
>
> >> f1 :: Int -> Int
> >> f1 x
> >> | trace ("The initial value is " ++ show x) False = undefined
> >> | otherwise = f2 x
> >
> > In general, the 'trace ... False = undefined' thing is
> > quite useful
>
> How is it better than
>
> > f1 x = tra
Hal Daume III <[EMAIL PROTECTED]> writes:
>> f1 :: Int -> Int
>> f1 x
>> | trace ("The initial value is " ++ show x) False = undefined
>> | otherwise = f2 x
>
> In general, the 'trace ... False = undefined' thing is
> quite useful
How is it better than
> f1 x = trace ("The initial value is
On Mon, Oct 13, 2003 at 06:32:14PM +0100, Jose Morais wrote:
> Hi,
>
> What I needed was actualy something more like
>
> f3 :: Int -> String
> f3 x = show x ++ f4 x
>
> f4 :: Int -> IO String
> f4 x = do
> putStr ("initial value i
Hi,
What I needed was actualy something more like
f3 :: Int -> String
f3 x = show x ++ f4 x
f4 :: Int -> IO String
f4 x = do
putStr ("initial value is " ++ show x)
return (show x)
but this gives the error
Type checking
ERROR "teste.h
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 ::
In general, you can't, not with these type signatures, since printing
something is a side effect.
If this is only for debugging purposes, you might try using trace from
IOExts. You can use it in a nice fashion like:
> f1 :: Int -> Int
> f1 x
> | trace ("The initial value is " ++ show x) Fal
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.
How could I do this?
Thank you
__