module Language.Maude.Exec.Types
(
MaudeException(..)
, MaudeCommand(..)
, MaudeConf(..)
, MaudeResult(..)
, RewriteResult(..)
, SearchResult(..)
, SearchResults
, Substitution(..)
, MaudeStatistics(..)
) where
import Control.Exception
import Data.Data
import Data.Text (Text)
import System.Exit (ExitCode)
import qualified Text.XML.Light as XML
import Language.Maude.Syntax
data MaudeException
= MaudeFailure
{ maudeFailureExitCode :: ExitCode
, maudeFailureStderr :: Text
, maudeFailureStdout :: Text
}
| LogToXmlFailure
| XmlToResultFailure String XML.Element
deriving (Typeable)
instance Exception MaudeException
instance Show MaudeException where
showsPrec _ (MaudeFailure e err out)
= showString "MaudeFailure (exitCode = " . showsPrec 0 e
. showString ") (stderr = " . showsPrec 0 err
. showString ") (stdout = " . showsPrec 0 out . showChar ')'
showsPrec _ LogToXmlFailure = showString "LogToXmlFailure"
showsPrec _ (XmlToResultFailure s e)
= showString "XmlToResultFailure " . showsPrec 0 s
. showString "\n" . showString (take n xml)
. showString (if length xml > n then "..." else "")
where
n = 100
xml = XML.showElement e
data MaudeCommand
= Rewrite Text
| Erewrite Text
| Search Text Text
deriving (Eq, Ord, Show, Data, Typeable)
data MaudeConf = MaudeConf
{ maudeCmd :: FilePath
, loadFiles :: [FilePath]
} deriving (Eq, Ord, Show, Data, Typeable)
data MaudeResult
= MaudeResult
{ maudeStdout :: Text
, maudeXmlLog :: Text
}
deriving (Eq, Ord, Show, Data, Typeable)
data RewriteResult = RewriteResult
{ resultTerm :: Term
, rewriteStatistics :: MaudeStatistics
} deriving (Eq, Ord, Show, Data, Typeable)
data SearchResult = SearchResult
{ searchSolutionNumber :: Integer
, searchStatistics :: MaudeStatistics
, searchResult :: Substitution
} deriving (Eq, Ord, Show, Data, Typeable)
type SearchResults = [SearchResult]
data Substitution = Substitution Term Term
deriving (Eq, Ord, Show, Data, Typeable)
data MaudeStatistics = MaudeStatistics
{ totalRewrites :: Integer
, realTime :: Integer
, cpuTime :: Integer
} deriving (Eq, Ord, Show, Data, Typeable)