[Haskell-beginners] populating a bloom filter; stymied by ST monad
Joey Hess
joey at kitenet.net
Tue Mar 13 16:16:12 CET 2012
Chaddaï Fouché wrote:
> getValues update initial = go initial =<< gen
> where
> go v [] = return v
> go v (f:fs) = do
x <- val f
>
> You say that this stream lazily, so I deduce that gen produce a lazy
> IO list. So you should be able to use gen in conjunction with easyList
> to get your bloom filter lazily. I'm not sure what the problem is ?
> How exactly do you get the elements of your bloom filter from gen
> input ?
gen produces a lazy list, but it's then transformed using another IO
operation. I added the relevant line back above. I did it that way to
preserve laziness. An alternate, simpler getvalues suitable for
easyList[1] would be the following, but due to the sequencing done by
mapM, the list does not stream out lazily.
getValues :: IO [v]
getValues update initial = mapM val =<< gen
--
see shy jo
[1] If easyList didn't also destroy laziness by running length, anyway..
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 828 bytes
Desc: Digital signature
URL: <http://www.haskell.org/pipermail/beginners/attachments/20120313/fe0f0067/attachment.pgp>
More information about the Beginners
mailing list