ndmitchell / debug

Haskell library for debugging
BSD 3-Clause "New" or "Revised" License
122 stars 7 forks source link

Multiple observations of the same variable in a function call #28

Open pepeiborra opened 6 years ago

pepeiborra commented 6 years ago

Consider the example

debug [d|
       listcomp y = sum [x | x <- [1..y]]
  |]

The expression listcomp 3 Produces the trace

     * listcomp 3 = 6
     x = 1
     x = 2
     x = 3
     $arg1 = 3
     y = 3
     sum = 6
     $result = 6

This is not unique to list comprehensions, it happens also for a mapped lambda:

debug [d|
       listmap y = sum $ map (\x -> x) [1..y]
  |]

listmap 3 produces the same trace as listcomp 3

The Hoed backend is not affected by this.