type Env = Name -> Action Val evaluate env x = case x of ... Ref n -> ... App f a -> with_fun ( evaluate env f ) $ \ fun -> fun ( evaluate env a ) data Val = ... | ValFun ...