2008/10/13 Daryoush Mehrtash <[EMAIL PROTECTED]>: > Is there a write up on what makes an implementation lazy vs strict?
I would be interested in seeing this, too! > I like to better understand the trade off between the two and use cases > where one is better than the other. > > I noticed that some functions in the lazy implementation uses "~" . For > example > > evalStateT :: (Monad m) => StateT s m a -> s -> m a > > evalStateT m s = do > ~(a, _) <- runStateT m s > > return a > > What does ~ do? Here's one I can answer. ~ causes Haskell to do the pattern match lazily. Normally, when you write (a,_) <- runStateT m s it eagerly evaluates the runStateT m s far enough to determine that the result is in fact a tuple in the underlying monad (as opposed to, say, fail). Adding the ~ tells Haskell to not do any computation until it actually needs the value of a. You can find a better explanation and examples at http://en.wikibooks.org/wiki/Haskell/Laziness Cheers, steve _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe