[Haskell-beginners] [Haskell-cafe] select :: [(Float, a)] -> a -- Weighted stochastic selection - help?

Brandon S. Allbery KF8NH allbery at ece.cmu.edu
Sat Sep 6 11:20:10 EDT 2008

On 2008 Sep 6, at 6:04, C.M.Brown wrote:
> On Sat, 6 Sep 2008, Nicolas Pouillard wrote:
>> Excerpts from C.M.Brown's message of Fri Sep 05 22:12:05 +0200 2008:
>>>> Can you give an example? I don't see how that can be done using
>>>> Control.Monad.State(.Strict).State, unless invocations of put or  
>>>> modify are
>>>> considered side effects.
>>> Actually, yes, sorry; I do see your point. I guess it's just IO  
>>> then.
>> Technically, even the IO monad is pure, that's just the runtime- 
>> system
>> that consume your 'main' function that perform effects (and  
>> unsafeP...).
> But, sure the IO monad does have side-effects? I'm confused as to  
> how it
> could be pure. Could you explain?

Technically (in GHC at least) the IO monad builds a pure chain of  
function applications and returns it from main, which then implicitly  
passes it to an otherwise inacccessible runIO.  Laziness makes this  
indistinguishable in practice from making effectful calls.

brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery at kf8nh.com
system administrator [openafs,heimdal,too many hats] allbery at ece.cmu.edu
electrical and computer engineering, carnegie mellon university    KF8NH

More information about the Beginners mailing list