parseCase = do reserved "case"
               t <- parseTerm
               reserved "of"
               liftM (TmCase t) $ sepBy1 parseBranch (symbol "|")
    where parseBranch = do symbol "<"
                           label <- identifier
                           symbol "="
                           var <- identifier
                           symbol ">"
                           symbol "==>"
                           ctx <- getState
                           setState $ appendBinding var NameBind ctx
                           t <- parseTerm
                           setState ctx
                           return (label, (var,t))

{- ------------------------------
   Exceptions
   ------------------------------ -}
parseCase = do reserved "case"
               t <- parseTerm
               reserved "of"
               liftM (TmCase t) $ sepBy1 parseBranch (symbol "|")
    where parseBranch = do symbol "<"
                           label <- identifier
                           symbol "="
                           var <- identifier
                           symbol ">"
                           symbol "==>"
                           ctx <- getState
                           setState $ appendBinding var NameBind ctx
                           t <- parseTerm
                           setState ctx
                           return (label, (var,t))

{- ------------------------------
   Exceptions
   ------------------------------ -}
parseCase = do reserved "case"
               t <- parseTerm
               reserved "of"
               liftM (TmCase t) $ sepBy1 parseBranch (symbol "|")
    where parseBranch = do symbol "<"
                           label <- identifier
                           symbol "="
                           var <- identifier
                           symbol ">"
                           symbol "==>"
                           ctx <- getState
                           setState $ appendBinding var NameBind ctx
                           t <- parseTerm
                           setState ctx
                           return (label, (var,t))

{- ------------------------------
   Exceptions
   ------------------------------ -}