`let' for comprehension

Simon Marlow simonmarhaskell at gmail.com
Fri Aug 25 05:04:47 EDT 2006


Serge D. Mechveliani wrote:
> Who can advise, please, 
> 
> is this for sure that the program
> 
>    \ x ->  [f y | y <- g x]
> 
> is not more expensive in computation than
> 
>    \ x ->  let  ys = g x  in  [f y | y <- ys]
> ?
> May the difference depend on Haskell implementation?

In GHC (and probably JHC) it shouldn't make any difference, in other compilers 
it might do.

Cheers,
	Simon


More information about the Glasgow-haskell-users mailing list