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

Brent Yorgey byorgey at seas.upenn.edu
Wed Jan 12 22:51:57 CET 2011


On Wed, Jan 12, 2011 at 12:19:50AM +0100, Tim Baumgartner wrote:
> 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'

As a side note, the MonadRandom constraint is funny, since this
function doesn't depend on any sort of randomness.  You may consider
changing the constraint to simply Monad m => ...

-Brent



More information about the Haskell-Cafe mailing list