[Haskell-cafe] MonadRandom-computation that does not terminate

Tim Baumgartner baumgartner.tim at googlemail.com
Wed Jan 12 00:19:50 CET 2011


Hi,

I'm having difficulties with this function I wrote:

iterateR :: (MonadRandom m) => (a -> m a) -> a -> m [a]
iterateR g s = do
  s' <- g s
  return (s:) `ap` iterateR g s'

I'm running the computation with evalRandIO and surprisingly the first call
of main in ghci succeeds, but the second does not terminate. Reproducible.
Any clues what I'm doing wrong here?

Thanks in advance,
Tim
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20110112/8e9156f0/attachment.htm>


More information about the Haskell-Cafe mailing list