Send Beginners mailing list submissions to
        [email protected]

To subscribe or unsubscribe via the World Wide Web, visit
        http://www.haskell.org/mailman/listinfo/beginners
or, via email, send a message with subject or body 'help' to
        [email protected]

You can reach the person managing the list at
        [email protected]

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Beginners digest..."


Today's Topics:

   1.  GHC 6.12, -fwarn-unused-do-bind and Text.Printf (Iustin Pop)
   2. Re:  GHC 6.12,    -fwarn-unused-do-bind and Text.Printf
      (Daniel Fischer)
   3. Re:  GHC 6.12, -fwarn-unused-do-bind and  Text.Printf
      (Nicolas Pouillard)
   4. Re:  GHC 6.12, -fwarn-unused-do-bind and  Text.Printf
      (Roel van Dijk)
   5.  Problem with GHCI. (Chimpion Chimpion)
   6.  Re: Problem with GHCI. (Chimpion Chimpion)
   7. Re:  Re: Problem with GHCI. (Mihai Maruseac)
   8. Re:  Re: Problem with GHCI. (Jorden Mauro)
   9. Re:  Re: Problem with GHCI. (Chimpion Chimpion)


----------------------------------------------------------------------

Message: 1
Date: Mon, 22 Feb 2010 23:02:13 +0100
From: Iustin Pop <[email protected]>
Subject: [Haskell-beginners] GHC 6.12, -fwarn-unused-do-bind and
        Text.Printf
To: Haskell Beginners <[email protected]>
Message-ID: <[email protected]>
Content-Type: text/plain; charset=us-ascii

Hi there,

I'm trying to upgrade some code to ghc 6.12 but under -Wall, the new
warning about unused do binds is triggering on Text.Printf.printf usage.

This code:

import Text.Printf

main :: IO ()
main = do
  printf "Hello, world\n"
  printf "Hello the second time\n"

When run with runhaskell -Wall gives:

Warning: A do-notation statement discarded a result of type
GHC.Prim.Any. Suppress this warning by saying "_ <- printf "Hello,
world\n"", or by using the flag -fno-warn-unused-do-bind.

Now, I'm confused why such a simple usage of printf triggers this
warning; enforcing the first printf to type IO () fixes the warning, but
it seems strange to no longer be able to simply write printf.

Anyone knows a workaround, or can enlighten me what I'm doing wrong?

A side question would be why we have "instance PrintfType (IO a)"
instead of "instance PrintfType (IO ())"; what use is there for that
generic type? Can printf return anything else than IO () (when used
under IO at all)?

thanks,
iustin


------------------------------

Message: 2
Date: Mon, 22 Feb 2010 23:47:09 +0100
From: Daniel Fischer <[email protected]>
Subject: Re: [Haskell-beginners] GHC 6.12,      -fwarn-unused-do-bind and
        Text.Printf
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain;  charset="iso-8859-1"

Am Montag 22 Februar 2010 23:02:13 schrieb Iustin Pop:
> Hi there,
>
> I'm trying to upgrade some code to ghc 6.12 but under -Wall, the new
> warning about unused do binds is triggering on Text.Printf.printf usage.
>
> This code:
>
> import Text.Printf
>
> main :: IO ()
> main = do
>   printf "Hello, world\n"
>   printf "Hello the second time\n"
>
> When run with runhaskell -Wall gives:
>
> Warning: A do-notation statement discarded a result of type
> GHC.Prim.Any. Suppress this warning by saying "_ <- printf "Hello,
> world\n"", or by using the flag -fno-warn-unused-do-bind.
>
> Now, I'm confused why such a simple usage of printf triggers this
> warning;

Because you don't bind the result of the first printf, which could be any 
type, so potentially interesting. The compiler doesn't know that 'printf 
fmt args' only ever returns undefined.

> enforcing the first printf to type IO () fixes the warning,

Yep, the compiler knows that a return value of type () is uninteresting 
enough to be discarded without warning.

> but it seems strange to no longer be able to simply write printf.
>
> Anyone knows a workaround, or can enlighten me what I'm doing wrong?

a) one of the options the compiler offered
b) expression type signature
c) use (>>) to explicitly tell the compiler "I want to discard the return 
value"

I'd probably use -fno-warn-unused-do-bind (as an OPTIONS_GHC pragma in the 
relevant files).

>
> A side question would be why we have "instance PrintfType (IO a)"
> instead of "instance PrintfType (IO ())";

Very good question.

> what use is there for that
> generic type? Can printf return anything else than IO () (when used
> under IO at all)?
>
> thanks,
> iustin



------------------------------

Message: 3
Date: Mon, 22 Feb 2010 22:37:59 -0800 (PST)
From: Nicolas Pouillard <[email protected]>
Subject: Re: [Haskell-beginners] GHC 6.12, -fwarn-unused-do-bind and
        Text.Printf
To: Iustin Pop <[email protected]>,       Haskell Beginners
        <[email protected]>
Message-ID: <[email protected]>

On Mon, 22 Feb 2010 23:02:13 +0100, Iustin Pop <[email protected]> wrote:
> Hi there,
> 
> I'm trying to upgrade some code to ghc 6.12 but under -Wall, the new
> warning about unused do binds is triggering on Text.Printf.printf usage.
> 
> This code:
> 
> import Text.Printf
> 
> main :: IO ()
> main = do
>   printf "Hello, world\n"
>   printf "Hello the second time\n"
> 
> When run with runhaskell -Wall gives:
> 
> Warning: A do-notation statement discarded a result of type
> GHC.Prim.Any. Suppress this warning by saying "_ <- printf "Hello,
> world\n"", or by using the flag -fno-warn-unused-do-bind.
> 
> Now, I'm confused why such a simple usage of printf triggers this
> warning; enforcing the first printf to type IO () fixes the warning, but
> it seems strange to no longer be able to simply write printf.
> 
> Anyone knows a workaround, or can enlighten me what I'm doing wrong?

What about providing a printf_ function with "IO ()" as return type?
(like mapM vs mapM_)

-- 
Nicolas Pouillard
http://nicolaspouillard.fr


------------------------------

Message: 4
Date: Tue, 23 Feb 2010 11:22:24 +0100
From: Roel van Dijk <[email protected]>
Subject: Re: [Haskell-beginners] GHC 6.12, -fwarn-unused-do-bind and
        Text.Printf
To: Haskell Beginners <[email protected]>
Message-ID:
        <[email protected]>
Content-Type: text/plain; charset=ISO-8859-1

On Mon, Feb 22, 2010 at 11:02 PM, Iustin Pop <[email protected]> wrote:
> A side question would be why we have "instance PrintfType (IO a)"
> instead of "instance PrintfType (IO ())"; what use is there for that
> generic type? Can printf return anything else than IO () (when used
> under IO at all)?

I can only guess, but perhaps because "instance PrintfType (IO ())"
would require the FlexibleInstances language extension. I believe the
current implementation of printf is fully Haskell98.


------------------------------

Message: 5
Date: Wed, 24 Feb 2010 00:05:58 +0530
From: Chimpion Chimpion <[email protected]>
Subject: [Haskell-beginners] Problem with GHCI.
To: [email protected]
Message-ID:
        <[email protected]>
Content-Type: text/plain; charset="iso-8859-1"

Could anyone tell me why this might be happening? I was trying to add some
modules to the GHCi(:d +...).

    Couldn't match expected type `String -> IO String'
           against inferred type `()'
    In the expression: ()
    In the expression: () :: String -> IO String
    In the definition of `__cmCompileExpr':
        __cmCompileExpr = () :: String -> IO String

Thank you.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
http://www.haskell.org/pipermail/beginners/attachments/20100223/f2aa0003/attachment-0001.html

------------------------------

Message: 6
Date: Wed, 24 Feb 2010 00:09:02 +0530
From: Chimpion Chimpion <[email protected]>
Subject: [Haskell-beginners] Re: Problem with GHCI.
To: [email protected]
Message-ID:
        <[email protected]>
Content-Type: text/plain; charset="iso-8859-1"

Prelude> :d +Monad

<interactive>:1:22:
    Couldn't match expected type `String -> IO String'
           against inferred type `()'
    In the expression: ()
    In the expression: () :: String -> IO String
    In the definition of `__cmCompileExpr':
        __cmCompileExpr = () :: String -> IO String

That is the actual thing.

On 24 February 2010 00:05, Chimpion Chimpion <[email protected]>wrote:

> Could anyone tell me why this might be happening? I was trying to add some
> modules to the GHCi(:d +...).
>
>     Couldn't match expected type `String -> IO String'
>            against inferred type `()'
>     In the expression: ()
>     In the expression: () :: String -> IO String
>     In the definition of `__cmCompileExpr':
>         __cmCompileExpr = () :: String -> IO String
>
> Thank you.
>
>
>


-- 
What we've got here is a failure to communicate.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
http://www.haskell.org/pipermail/beginners/attachments/20100223/9581fa50/attachment-0001.html

------------------------------

Message: 7
Date: Tue, 23 Feb 2010 20:42:07 +0200
From: Mihai Maruseac <[email protected]>
Subject: Re: [Haskell-beginners] Re: Problem with GHCI.
To: Chimpion Chimpion <[email protected]>
Cc: [email protected]
Message-ID:
        <[email protected]>
Content-Type: text/plain; charset=ISO-8859-1

On Tue, Feb 23, 2010 at 8:39 PM, Chimpion Chimpion
<[email protected]> wrote:
> Prelude> :d +Monad
>
> <interactive>:1:22:
>     Couldn't match expected type `String -> IO String'
>            against inferred type `()'
>     In the expression: ()
>     In the expression: () :: String -> IO String
>     In the definition of `__cmCompileExpr':
>         __cmCompileExpr = () :: String -> IO String
>
> That is the actual thing.
>
> On 24 February 2010 00:05, Chimpion Chimpion <[email protected]>
> wrote:
>>
>> Could anyone tell me why this might be happening? I was trying to add some
>> modules to the GHCi(:d +...).
>>
>>     Couldn't match expected type `String -> IO String'
>>            against inferred type `()'
>>     In the expression: ()
>>     In the expression: () :: String -> IO String
>>     In the definition of `__cmCompileExpr':
>>         __cmCompileExpr = () :: String -> IO String
>>
>> Thank you.

Try :m +Control.Monad (if it is the same)


------------------------------

Message: 8
Date: Tue, 23 Feb 2010 13:42:44 -0500
From: Jorden Mauro <[email protected]>
Subject: Re: [Haskell-beginners] Re: Problem with GHCI.
To: Chimpion Chimpion <[email protected]>
Cc: [email protected]
Message-ID:
        <[email protected]>
Content-Type: text/plain; charset=ISO-8859-1

On Tue, Feb 23, 2010 at 1:39 PM, Chimpion Chimpion
<[email protected]> wrote:
> Prelude> :d +Monad
>
> <interactive>:1:22:
>     Couldn't match expected type `String -> IO String'
>            against inferred type `()'
>     In the expression: ()
>     In the expression: () :: String -> IO String
>     In the definition of `__cmCompileExpr':
>         __cmCompileExpr = () :: String -> IO String
>
> That is the actual thing.
>
> On 24 February 2010 00:05, Chimpion Chimpion <[email protected]>
> wrote:
>>
>> Could anyone tell me why this might be happening? I was trying to add some
>> modules to the GHCi(:d +...).
>>
>>     Couldn't match expected type `String -> IO String'
>>            against inferred type `()'
>>     In the expression: ()
>>     In the expression: () :: String -> IO String
>>     In the definition of `__cmCompileExpr':
>>         __cmCompileExpr = () :: String -> IO String
>>
>> Thank you.

:m +Monad

:d is for something else.


------------------------------

Message: 9
Date: Wed, 24 Feb 2010 00:48:24 +0530
From: Chimpion Chimpion <[email protected]>
Subject: Re: [Haskell-beginners] Re: Problem with GHCI.
To: Jorden Mauro <[email protected]>
Cc: [email protected]
Message-ID:
        <[email protected]>
Content-Type: text/plain; charset="iso-8859-1"

Oh alright. I was doing the wrong thing. Sorry for the bother.
Thank you.

On 24 February 2010 00:12, Jorden Mauro <[email protected]> wrote:

> On Tue, Feb 23, 2010 at 1:39 PM, Chimpion Chimpion
> <[email protected]> wrote:
> > Prelude> :d +Monad
> >
> > <interactive>:1:22:
> >     Couldn't match expected type `String -> IO String'
> >            against inferred type `()'
> >     In the expression: ()
> >     In the expression: () :: String -> IO String
> >     In the definition of `__cmCompileExpr':
> >         __cmCompileExpr = () :: String -> IO String
> >
> > That is the actual thing.
> >
> > On 24 February 2010 00:05, Chimpion Chimpion <[email protected]>
> > wrote:
> >>
> >> Could anyone tell me why this might be happening? I was trying to add
> some
> >> modules to the GHCi(:d +...).
> >>
> >>     Couldn't match expected type `String -> IO String'
> >>            against inferred type `()'
> >>     In the expression: ()
> >>     In the expression: () :: String -> IO String
> >>     In the definition of `__cmCompileExpr':
> >>         __cmCompileExpr = () :: String -> IO String
> >>
> >> Thank you.
>
> :m +Monad
>
> :d is for something else.
>



-- 
What we've got here is a failure to communicate.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
http://www.haskell.org/pipermail/beginners/attachments/20100223/a0fa1533/attachment.html

------------------------------

_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners


End of Beginners Digest, Vol 20, Issue 35
*****************************************

Reply via email to