import Lambda.Util

----------------------------------------------------------------------
-- gointoCaseRoute
----------------------------------------------------------------------

gointoCaseRoute :: Term -> [(PM, Term)] -> Lambda Term
gointoCaseRoute x ((pm,t):pairs) = do
    if x == convert pm
    then (*:) t
    else case pairs of
            [] -> do e <- restore x 
                     throwEvalError $ strMsg $ "CASE: unexhausted pattern: "++ show e
            _  -> gointoCaseRoute x pairs
