matchCandidate :: (DefStore d) => d -> [(MatchOp, MatchOp)]
               -> IO (Either String MatchResult)
matchCandidate def = f emptyMatchResult where
    f mtch [] = return $ Right mtch
    f mtch ((pat, c) : l) = do
      let e = getEnv def
      logMsg def $ text "Matching Candidate Pattern"
                 $+$ prettyInEnv e pat $+$ text " with" $+$ prettyInEnv e c
      res <- match def mtch (candTerm pat) $ candTerm c
      case res of
        Right mtch' -> f mtch' l
        x -> return x
matchCandidate :: (DefStore d) => d -> [(MatchOp, MatchOp)]
               -> IO (Either String MatchResult)
matchCandidate def = f emptyMatchResult where
    f mtch [] = return $ Right mtch
    f mtch ((pat, c) : l) = do
      let e = getEnv def
      logMsg def $ text "Matching Candidate Pattern"
                 $+$ prettyInEnv e pat $+$ text " with" $+$ prettyInEnv e c
      res <- match def mtch (candTerm pat) $ candTerm c
      case res of
        Right mtch' -> f mtch' l
        x -> return x
matchCandidate def = f emptyMatchResult where
    f mtch [] = return $ Right mtch
    f mtch ((pat, c) : l) = do
      let e = getEnv def
      logMsg def $ text "Matching Candidate Pattern"
                 $+$ prettyInEnv e pat $+$ text " with" $+$ prettyInEnv e c
      res <- match def mtch (candTerm pat) $ candTerm c
      case res of
        Right mtch' -> f mtch' l
        x -> return x