[Haskell-cafe] trace

Daniel Fischer daniel.is.fischer at web.de
Thu Dec 24 15:52:46 EST 2009


Am Donnerstag 24 Dezember 2009 21:31:34 schrieb michael rice:
> Can someone provide a simple example of tracing a function.
>
> Michael

Is

import Debug.Trace

infixl 0 `debug`

debug = flip trace

dfib :: Int -> Integer
dfib =
    let fib 0 = 0
        fib 1 = 1
        fib n = dfib (n-2) + dfib (n-1) `debug` "eval fib " ++ show n
    in (map fib [0 .. ] !!)


*MFib> dfib 12
eval fib 12
eval fib 10
eval fib 8
eval fib 6
eval fib 4
eval fib 2
eval fib 3
eval fib 5
eval fib 7
eval fib 9
eval fib 11
144

the kind of example you're looking for?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091224/78f294aa/attachment.html


More information about the Haskell-Cafe mailing list