Lazy bind...

Martin Norbäck
30 Jul 2002 14:48:59 +0200

Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

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 >>=3D \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 >>=3D
for the monad in question. Since the point of the IO monad is to
sequentialize IO operations, >>=3D will definititely not be lazy there.

Perhaps if you give a concrete example of what you want to do, people
could help you more.



Martin Norb=E4ck             =20
Kapplandsgatan 40       +46 (0)708 26 33 60                   =20
S-414 78  G=D6TEBORG
SWEDEN                  OpenPGP ID: 3FA8580B

Content-Type: application/pgp-signature; name=signature.asc

Version: GnuPG v1.0.6 (GNU/Linux)
Comment: För information se