[Haskell-cafe] Detecting Cycles in Datastructures
Iavor Diatchki
iavor.diatchki at gmail.com
Thu Oct 27 13:28:01 EDT 2005
Hello,
On 10/27/05, Tom Hawkins <tom at confluent.org> wrote:
> ...
> >> data Expr = Constant Int | Addition Expr Expr
> >>
> >> cyclic :: Expr
> >> cyclic = Addition (Constant 1) cyclic
> ...
> > And there is nothing that says that your definition of cyclic
> > will actually have a cycle in the implementation.
>
> Would you elaborate? Are you referring to the possibility that
> "cyclic", or at least the second Addition operand, may not be evaluated?
An implementation that does not do updating of values (i.e. uses "call
by name" instead of "call by need") will not generate a cyclic
structure; instead every time you ask for the value of "cyclic" it
will create a new expression.
-Iavor
More information about the Haskell-Cafe
mailing list