Re: IO Bool - Bool
In article [EMAIL PROTECTED], Tn X-10n [EMAIL PROTECTED] wrote: is it possible to convert IO Bool to Bool? Not directly in Haskell, but you can use the - syntax to do something vaguely similar inside a do block. For instance: foo :: IO Bool do result - foo if result then putStrLn yes else return () Here result has type Bool. do blocks are magic conjured from sugar and syntax. -- Ashley Yakeley, Seattle WA ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: IO Bool - Bool
On Thu, 14 Aug 2003, Wolfgang Jeltsch wrote: On Thursday, 2003-08-14, 17:05, CEST, Kevin S. Millikin wrote: On Wednesday, August 13, 2003 11:20 PM, Tn X-10n [SMTP:[EMAIL PROTECTED] wrote: is it possible to convert IO Bool to Bool? Sure. Which Bool do you want? True? toTrue :: IO Bool - Bool toTrue x = True Or False? toFalse :: IO Bool - Bool toFalse x = False There's also boolFromIO :: IO Bool - Bool boolFromIO = boolFromIO if you want to be even less useful :) I wouldn't call these *conversion* functions because they don't look at their argument. Maybe that's not what you had in mind. Surely not. Wolfgang I'm surprise nobody has mentioned unsafePerformIO (:: IO a - a). As the name suggests, it isn't referentially transparent. Are you sure you need a function of type IO Bool - Bool? What are you trying to do? Brandon ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: IO Bool - Bool
On Thursday 14 August 2003 06:20, Tn X-10n wrote: htmldiv style='background-color:'DIV PBRhai guys/Pis it possible to convert IO Bool to Bool?/DIV/divbr clear=allhrGet 10mb of e-mail space with a href=http://g.msn.com/8HMTENSG/2737??PS=;MSN Hotmail Extra Storage/a at only S$36 per year including GST/html It makes no sense to convert an IO Bool to a Bool. If something has type IO Bool that means it is an action which will get a Bool from the outside world. It cannot be converted into a Bool. If you want to use the action to get a Bool from the outside world you should invoke the action in somewhere in the IO part of your code, like this.. do ... boolVal - ioBoolAction ... Regards -- Adrian Hey ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: IO Bool - Bool
On Thursday, 2003-08-14, 17:05, CEST, Kevin S. Millikin wrote: On Wednesday, August 13, 2003 11:20 PM, Tn X-10n [SMTP:[EMAIL PROTECTED] wrote: is it possible to convert IO Bool to Bool? Sure. Which Bool do you want? True? toTrue :: IO Bool - Bool toTrue x = True Or False? toFalse :: IO Bool - Bool toFalse x = False I wouldn't call these *conversion* functions because they don't look at their argument. Maybe that's not what you had in mind. Surely not. Wolfgang ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe
RE: IO Bool - Bool
On Wednesday, August 13, 2003 11:20 PM, Tn X-10n [SMTP:[EMAIL PROTECTED] wrote: is it possible to convert IO Bool to Bool? Sure. Which Bool do you want? True? toTrue :: IO Bool - Bool toTrue x = True Or False? toFalse :: IO Bool - Bool toFalse x = False Maybe that's not what you had in mind. ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: IO Bool - Bool
PBRhai guys/Pis it possible to convert IO Bool to Bool? No, it's not... and for good reason! See the discussion at http://www.haskell.org/hawiki/ThatAnnoyingIoType and http://www.haskell.org/hawiki/UsingIo In general, the HaWiki has answers to lots of newbie questions like this - you might find it useful to peruse (although you should certainly continue to ask questions here too - we're a pretty friendly bunch!). Best wishes, --KW 8-) -- Keith Wansbrough [EMAIL PROTECTED] http://www.cl.cam.ac.uk/users/kw217/ University of Cambridge Computer Laboratory. ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: IO Bool - Bool
On Thursday, 2003-08-14, 07:20, CEST, Tn X-10n wrote: hai guys is it possible to convert IO Bool to Bool? No. The reason for introducing the IO type is to preserve the purity of Haskell, i.e., to ensure that expression evaluation doesn't depend on the state of the outside world and doesn't alter this state.*) Allowing a conversion from IO t to t would nullify this. As you might have noticed, there was (or still is) a discussion about yet another monad tutorial on The Haskell Cafe. Some of the messenges and, above all, the monad tutorial itself may help you understand how I/O in Haskell works. There is not a quick answer to your question like: This way you convert an IO Bool to a Bool. You will have to do some reading to understand the basic ideas of I/O in Haskell. They are quiet different from what you might know from other programming languages. Wolfgang *) This is at least how I would formulate it, others would probably phrase it a bit different. ;-) P.S.: Would you mind to configure your mail client such that your mails also contain a plain text variant of your message? ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe