Debug: View variable value in recursion. Is it possible?

  • Vlatko Basic

    Vlatko Basic - 2013-03-05

    I was trying to debug this simple function with recursion. Debuging and stepping works, but list variables (xs,ys,zs) are empty (_),

        combinations'  :: Int -> [a] -> [[a]]
        combinations'  0 _  = [ [] ]
        combinations' n xs = [ y:ys | y:zs <- tails xs, ys <- combinations' (n-1) zs]

    I suspect it has to do with Haskell being lazy, but is there a way to see the current state of list variables in a breakpoint step (without changing the source, like with trace)?


        xs = [1,2,3] 
        zs = [2,3] [3]...
  • JP Moresmau

    JP Moresmau - 2013-03-10

    In the "Variables" view of the "Debug" perspective, in the "Value" column, when you see "_", select the cell and enter a value (like a single space). This will cause a force calculation of the value, that will then appear in the cell.
    Note that forcing values may change behavior of your program in terms of space usage, for example, but is useful for debugging.

  • Vlatko Basic

    Vlatko Basic - 2013-03-11

    I tried it and it evaluates all the steps of recursion from that point to the end.
    Seems logical, but not exactly what I expected.
    Thanks for the tip, it helps.


Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.

No, thanks