Lazy bind...

Ken Shan ken@digitas.harvard.edu
Thu, 1 Aug 2002 01:08:04 -0400


--hoZxPH4CaxYzWscb
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On 2002-07-30T18:43:28+0100, MR K P SCHUPKE wrote:
> The data types I used are:
>=20
> data (Error e) =3D> Reply e s a=3D Ok [s] a | Empty | Fail e
> data (Error e) =3D> Result e s a =3D Accepted (Reply e s a) | Rejected
>=20
> newtype (Error e) =3D> Parser e s a =3D Parser {runParser :: [s] -> Resul=
t e s a}
>=20
> newtype (Error e,Monad m) =3D> ParserT e s m a =3D ParserT {runParserT ::=
 [s] ->
> m (Result e s a)}
>=20
> [...]
>=20
>     Hope this makes things clearer...

Yes!  Let me rephrase my earlier suggestion in terms of these actual
types.

For reasons that will soon become clear, let me begin by rearranging
Result a bit:

    data Result x =3D Accepted x | Rejected
    newtype (Error e) =3D> Parser e s a
	=3D Parser {runParser :: [s] -> Result (Reply e s a)}
    newtype (Error e, Monad m) =3D> ParserT e s m a
	=3D ParserT {runParserT :: [s] -> m (Result (Reply e s a))}

(Here I have removed the constraint "Error e" from the definition of
Result.  I don't think it will cause you much trouble.)

Now, what about the following alternative definition of ParserT?

    newtype (Error e, Monad m) =3D> ParserT e s m a
	=3D ParserT {runParserT :: [s] -> m (Result (m (Reply e s a)))}

Would it suit your purposes?

--=20
Edit this signature at http://www.digitas.harvard.edu/cgi-bin/ken/sig
When was the last time you wrote your representative in government?
And, vote, for those who can't.

--hoZxPH4CaxYzWscb
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (GNU/Linux)

iD8DBQE9SMIzzjAc4f+uuBURAqAcAKCvGdIMek6F2RJuwa2ts3S/g8agGwCdHWaG
27XOUG9NB5bZ9t2n82ceQuM=
=mE7R
-----END PGP SIGNATURE-----

--hoZxPH4CaxYzWscb--