This is a data type of lambda calculus and a shifting function. It does not matter what it does, don't look into details, look at the structure.
import Debug.Trace
data Term = Idx Int | Lam Term | Term :@: Term deriving (Read, Show, Eq)
shift :: Int -> Term -> Term
shift val term = go 0 val term
go :: Int -> Int -> Term -> Term
go m k term | trace ("myfun " ++ show m ++ " " ++ show k ++ " " ++ show term) False = undefined
go m k (Idx n) | n < m = Idx n
| otherwise = Idx (n + k)
go m k (a :@: b) = go m k a :@: go m k b
go m k (Lam a) = Lam $ go (m + 1) k a
It has several pattern-matching blocks by the same type.
What I want to do is to run
shift 5 (Lam (Lam (Idx 0 :@: Idx 1)))
and see, the order of execution with lines. Which go
function would be executed first, second and so on.
You can see, I included the tracing function. It's a good trick and I like that I have to include it once, to check the input of every pattern-matching implementation.
However, I want to have line numbers!
There is an answer that have line numbers, but it does not work for single_trace_for_whole_block https://stackoverflow.com/a/7253991/2787507
Maybe there are some Haskell libraries that gives this functionality?