[prev in list] [next in list] [prev in thread] [next in thread] 

List:       haskell-beginners
Subject:    Re: [Haskell-beginners] Re: Re: testing and the culture of Haskell
From:       Isaac Dupree <ml () isaac ! cedarswampstudios ! org>
Date:       2010-01-23 23:39:16
Message-ID: 4B5B88A4.9050407 () isaac ! cedarswampstudios ! org
[Download RAW message or body]

Adrian Adshead wrote:
> 1) Is it possible to have a function with an IO Action as an input
> parameter (and not just ignore the parameter) and have a non-IO
> return value?
> (ie is     f :: IO a -> b    possible without ignoring the IO a)

pretty much no, but consider, we can return a data structure constructed 
out of those IOs, without actually learning anything about what actions 
they are intended to do. For example:

f :: IO a -> [IO a]
f io = iterate (\io2 -> (io2 >> io2)) io

returns a list, in which the first action would do the IO once, the 
second would do it twice, the third element would do it four times, the 
fourth element, eight times, and so forth.

Obviously, it is only occasionally useful to do something strange like that.

-Isaac
_______________________________________________
Beginners mailing list
Beginners@haskell.org
http://www.haskell.org/mailman/listinfo/beginners
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic