You can't do it. The reason is that Haskell isn't supposed to perform lambda term reductions. Haskell evaluates programs (lambda terms) to values. One possibility how to do this would be to really perform lambda term reductions, but this would be quite inefficient. So Haskell compilers use many sophisticated techniques such as graph reduction instead. Therefore you can't observe differences such as (\x -> x) y
vs y
during the evaluation process - there are no actual lambda terms to be observed.
Note that GHC has NFData
type class which allows to evaluate terms to their normal forms using rnf
- r-educe to n-ormal f-orm (but only products or coproducts, it still doesn't evaluate terms under lambdas, as @JakeMcArthur pointed out). However, this doesn't give you access to the normal form expressed as a lambda term. It only tells Haskell to perform this evaluation during the computation.