[Haskell-cafe] couple of questions on monads
dmehrtash at gmail.com
Mon Oct 13 17:31:23 EDT 2008
Is there a write up on what makes an implementation lazy vs strict?
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
evalStateT :: (Monad m) => StateT s m a -> s -> m a
evalStateT m s = do
~(a, _) <- runStateT m s
What does ~ do?
On Mon, Oct 13, 2008 at 1:34 PM, Jonathan Cast <jonathanccast at fastmail.fm>wrote:
> On Mon, 2008-10-13 at 13:37 -0700, Daryoush Mehrtash wrote:
> > Question 1: Why are there lazy and strict modules of some monads?
> > (e.g. Control.Monad.State)
> Because both are useful, for different purposes. (For the same reason
> that it's helpful, in general, to have both eager and lazy evaluation in
> the same language --- sometimes one version is more efficient, sometimes
> the other one is).
> > Question 2: If I define a new monad (say XYZ), does it have to be as
> > Control.Monad.XYZ module?
> No. Haskell has neither a requirement nor a convention that monads go
> in Control.Monad. Control.Monad.* is simply the home of the MTL
> library, which contains a number of exceptionally useful monads; new
> monads that aren't as exceptionally general-purpose as MTL probably
> shouldn't go there, to reduce clutter.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe