I have a question :) What should I do if I have something like "IO Bool" and I need "Bool" ?? And the same with other IO +something. Thank You :)
Look through the mailing list archives/wiki/haskell tutorials. But basically you can't, except by combining it with another action, as in: suppose 'baz :: Int -> IO Bool', then: foo = do bar <- baz 5 if bar then ... else ... for instance... -- Hal Daume III | hdaume@isi.edu "Arrest this man, he talks in maths." | www.isi.edu/~hdaume On Wed, 11 Jun 2003, Filip wrote:
I have a question :) What should I do if I have something like "IO Bool" and I need "Bool" ?? And the same with other IO +something.
Thank You :) _______________________________________________ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell
On Wed, 11 Jun 2003 20:00:00 +0200 Filip <tomf16@poczta.onet.pl> wrote:
I have a question :) What should I do if I have something like "IO Bool" and I need "Bool" ??
Read the "Gentle Introduction" http://www.haskell.org/tutorial/
On Wed, 11 Jun 2003 20:00:00 +0200 Filip <tomf16@poczta.onet.pl> wrote:
What should I do if I have something like "IO Bool" and I need "Bool"
IO Bool means "an action that can perform IO and returns a Bool". You can't get a Bool without performing IO with that function, so you can't get a Bool from a "IO Bool"; indeed you can write your own action wich uses the function and its result. This action will "eventually perform IO", and so it will be IO <something>. see: http://www.haskell.org/hawiki/ThatAnnoyingIoType and read the gentle introduction as Derek Elkins told you. Vincenzo -- Scopriti essere umano e in quanto tale persona banale e non speciale a cui Dio concede gesti assai banali. D'ora in poi quello sei tu. [Marlene Kuntz]
On Wednesday, 2003-06-11, 20:00, Filip wrote:
I have a question :) What should I do if I have something like "IO Bool" and I need "Bool" ?? And the same with other IO +something.
This is a question which arises very often on this list. I think, you should read a tutorial like the Gentle Introduction To Haskell in order to thoroughly understand how I/O works in Haskell. In my opinion, it makes very little sense to learn Haskell I/O by asking different questions which arise during your work. I/O in Haskell is not that easy.
Thank You :)
Wolfgang
google: "What the hell are Monads" http://www.abercrombiegroup.co.uk/~noel/research/monads.html IO in haskell is really easy, iff you understand the sense of monads. to understand sth. like "IO Bool" you have to remember that i.e. an array is no defined data type without the definition of its entries. "[Bool]" is sth. like that, too. the data type does not contain one "[]" and one "Bool". "IO a" is in fact an Input-Output-operation with return type "a". imagine this: "State -> (State,a)" the world state changes and there is an "a" as result part. it is not possible (mathematical, not technical) to throw away the fact that it is a function changing the state. your main function is of type... main :: IO () where "()" means sth. like "void". the IOs have just to be concatenated to construct a program. main :: IO () main = putStr "Hello " >> return "world!" >>= putStrLn >> getChar >>= (\c -> putStrLn [c,c,c]) >> return () you have to write a line and press <Return>, then getChar reads the first Char of your line.
participants (6)
-
Derek Elkins -
Filip -
Hal Daume III -
Marc Ziegert -
Nick Name -
Wolfgang Jeltsch