her.esy.fun/src/posts/0010-Haskell-Now/fib_lazy_trace.hs

12 lines
256 B
Haskell
Raw Normal View History

2019-12-26 11:45:11 +00:00
import Debug.Trace
-- like + but each time this is evaluated print a trace
tracedPlus x y = trace ("> " ++ show x ++ " + " ++ show y) (x + y)
fib :: [Integer]
fib = 1:1:zipWith tracedPlus fib (tail fib)
main = do
print (fib !! 10)
print (fib !! 12)