check validity of evaluated function position

exercise 6.4.1
simple WAE interpreter in haskell