In attempting to devise a variant of cycle which did not keep its argument alive (for the purpose of cycle [1::Int..]), I came across this peculiar behavior:
import Debug.Trace cycle' :: (a -> [b]) -> [b] cycle' xs = xs undefined ++ cycle' xs > take 20 $ cycle' (const $ 1:2:3:4:trace "x" 5:[]) [1,2,3,4,x 5,1,2,3,4,5,1,2,3,4,5,1,2,3,4,5] Nuts. Oh, but wait: > take 20 $ cycle' (\_ -> 1:2:3:4:trace "x" 5:[]) [1,2,3,4,x 5,1,2,3,4,x 5,1,2,3,4,x 5,1,2,3,4,x 5] Hey, it worked! Can someone explain what the heck is going on here? Luke _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe