
tis 2002-07-30 klockan 14.41 skrev MR K P SCHUPKE:
Is there any way to do a lazy bind operation, something like
a <- $ getLine return (Constructor $ a)
this works for computations in the IO monad :-
a <- unsafeInterleaveIO getLine return (Constructor $ a)
but I need to do this for a general monad M.
Remember that the syntax a <- getLine return (Constructor a) is just sugar for getLine >>= \a -> return (Constructor a) so actually the bind is already lazy (lamba binding is lazy). The laziness of the construction here will depend on your definition of >>= for the monad in question. Since the point of the IO monad is to sequentialize IO operations, >>= will definititely not be lazy there. Perhaps if you give a concrete example of what you want to do, people could help you more. Regards, Martin -- Martin Norbäck d95mback@dtek.chalmers.se Kapplandsgatan 40 +46 (0)708 26 33 60 S-414 78 GÖTEBORG http://www.dtek.chalmers.se/~d95mback/ SWEDEN OpenPGP ID: 3FA8580B