[Haskell-cafe] Detecting Cycles in Datastructures

Tom Hawkins tom at confluent.org
Thu Oct 27 10:46:41 EDT 2005

In a pure language, is it possible to detect cycles in recursive data 
structures?  For example, is it possible to determine that "cyclic" has 
a loop? ...

data Expr = Constant Int | Addition Expr Expr

cyclic :: Expr
cyclic = Addition (Constant 1) cyclic

Or phased differently, is it possible to make "Expr" an instance of "Eq" 
such that cyclic == cyclic is smart enough to avoid a recursive decent?


More information about the Haskell-Cafe mailing list