Another question about sharing

Simon Marlow simonmar@microsoft.com
Mon, 10 Dec 2001 15:04:06 -0000


> Well, how about the following little circular program?
>=20
>         paths :: () -> [Path]
>     	paths () =3D let r =3D T : branch r in r
>=20
> As far as I can understand what you are looking for, I think=20
> this meets
> the bill.  Every use of the expression `paths ()' will re-evaluate
> the infinite structure to the extent its context requires it, and the
> expanded value will be thrown away as soon as the value of this
> instance of `paths ()' is no longer required.

You can't rely on adding dummy arguments to cause re-evaluation:
full-laziness (enabled when optimisation is on in GHC) will do the
opposite transformation.

Cheers,
	Simon