module CMDL.DataTypes
( CmdlState (..)
, emptyCmdlState
, CmdlCmdDescription (..)
, cmdInput
, cmdName
, CmdlCmdPriority (..)
, CmdlCmdFnClasses (..)
, NodeOrEdgeFilter (..)
, CmdlCmdRequirements (..)
, formatRequirement
, CmdlChannel (..)
, CmdlChannelType (..)
, CmdlChannelProperties (..)
, CmdlSocket (..)
, CmdlUseTranslation (..)
, CmdlProverConsChecker (..)
, CmdlPrompterState (..)
, CmdlMessage (..)
, emptyCmdlMessage
, CmdlListAction (..)
, CmdlGoalAxiom (..)
, ProveCmdType (..)
) where
import Interfaces.DataTypes
import Interfaces.Command
import Driver.Options
import Network.Socket
import Proofs.AbstractState (G_cons_checker)
import System.IO (Handle)
data CmdlGoalAxiom =
ChangeGoals
| ChangeAxioms
data CmdlProverConsChecker =
Use_prover
| Use_consChecker
data CmdlUseTranslation =
Do_translate
| Dont_translate
data CmdlState = CmdlState
{ CmdlState -> IntState
intState :: IntState
, CmdlState -> CmdlPrompterState
prompter :: CmdlPrompterState
, :: Bool
, CmdlState -> [CmdlChannel]
connections :: [CmdlChannel]
, CmdlState -> CmdlMessage
output :: CmdlMessage
, CmdlState -> HetcatsOpts
hetsOpts :: HetcatsOpts
, CmdlState -> Int
errorCode :: Int
, CmdlState -> [G_cons_checker]
consCheckers :: [G_cons_checker]
}
data ProveCmdType = Prove | Disprove | ConsCheck
emptyCmdlState :: HetcatsOpts -> CmdlState
emptyCmdlState :: HetcatsOpts -> CmdlState
emptyCmdlState opts :: HetcatsOpts
opts = CmdlState :: IntState
-> CmdlPrompterState
-> Bool
-> [CmdlChannel]
-> CmdlMessage
-> HetcatsOpts
-> Int
-> [G_cons_checker]
-> CmdlState
CmdlState
{ intState :: IntState
intState = IntState :: IntHistory -> Maybe IntIState -> String -> IntState
IntState
{ i_state :: Maybe IntIState
i_state = Maybe IntIState
forall a. Maybe a
Nothing
, i_hist :: IntHistory
i_hist = IntHistory :: [CmdHistory] -> [CmdHistory] -> IntHistory
IntHistory
{ undoList :: [CmdHistory]
undoList = []
, redoList :: [CmdHistory]
redoList = [] }
, filename :: String
filename = [] }
, prompter :: CmdlPrompterState
prompter = CmdlPrompterState :: String -> String -> CmdlPrompterState
CmdlPrompterState
{ fileLoaded :: String
fileLoaded = ""
, prompterHead :: String
prompterHead = "> " }
, output :: CmdlMessage
output = CmdlMessage
emptyCmdlMessage
, openComment :: Bool
openComment = Bool
False
, connections :: [CmdlChannel]
connections = []
, hetsOpts :: HetcatsOpts
hetsOpts = HetcatsOpts
opts
, errorCode :: Int
errorCode = 0
, consCheckers :: [G_cons_checker]
consCheckers = []
}
data CmdlPrompterState = CmdlPrompterState
{ CmdlPrompterState -> String
fileLoaded :: String
, CmdlPrompterState -> String
prompterHead :: String }
data CmdlCmdDescription = CmdlCmdDescription
{ CmdlCmdDescription -> Command
cmdDescription :: Command
, CmdlCmdDescription -> CmdlCmdPriority
cmdPriority :: CmdlCmdPriority
, CmdlCmdDescription -> CmdlCmdFnClasses
cmdFn :: CmdlCmdFnClasses
, CmdlCmdDescription -> CmdlCmdRequirements
cmdReq :: CmdlCmdRequirements }
instance Show CmdlCmdDescription where
show :: CmdlCmdDescription -> String
show cmd :: CmdlCmdDescription
cmd = Command -> String
forall a. Show a => a -> String
show (Command -> String) -> Command -> String
forall a b. (a -> b) -> a -> b
$ CmdlCmdDescription -> Command
cmdDescription CmdlCmdDescription
cmd
cmdInput :: CmdlCmdDescription -> String
cmdInput :: CmdlCmdDescription -> String
cmdInput = Command -> String
cmdInputStr (Command -> String)
-> (CmdlCmdDescription -> Command) -> CmdlCmdDescription -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CmdlCmdDescription -> Command
cmdDescription
cmdName :: CmdlCmdDescription -> String
cmdName :: CmdlCmdDescription -> String
cmdName = Command -> String
cmdNameStr (Command -> String)
-> (CmdlCmdDescription -> Command) -> CmdlCmdDescription -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CmdlCmdDescription -> Command
cmdDescription
data CmdlCmdPriority =
CmdNoPriority
|
| CmdGreaterThanScriptAndComments
data CmdlCmdFnClasses =
CmdNoInput (CmdlState -> IO CmdlState)
| CmdWithInput (String -> CmdlState -> IO CmdlState)
data NodeOrEdgeFilter = OpenCons | OpenGoals
data CmdlCmdRequirements =
ReqNodesOrEdges (Maybe Bool) (Maybe NodeOrEdgeFilter)
| ReqProvers
| ReqConsCheck
| ReqComorphism
| ReqLogic
| ReqFile
| ReqAxm Bool
| ReqNumber
| ReqNothing
| ReqUnknown
formatRequirement :: CmdlCmdRequirements -> String
formatRequirement :: CmdlCmdRequirements -> String
formatRequirement r :: CmdlCmdRequirements
r = let s :: String
s = CmdlCmdRequirements -> String
showRequirement CmdlCmdRequirements
r in
if String -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null String
s then "" else '<' Char -> ShowS
forall a. a -> [a] -> [a]
: String
s String -> ShowS
forall a. [a] -> [a] -> [a]
++ ">"
showRequirement :: CmdlCmdRequirements -> String
showRequirement :: CmdlCmdRequirements -> String
showRequirement cr :: CmdlCmdRequirements
cr = case CmdlCmdRequirements
cr of
ReqConsCheck -> "ConsChecker"
ReqProvers -> "Prover"
ReqComorphism -> "Comorphism"
ReqLogic -> "Logic"
ReqNodesOrEdges n :: Maybe Bool
n m :: Maybe NodeOrEdgeFilter
m -> String
-> (NodeOrEdgeFilter -> String) -> Maybe NodeOrEdgeFilter -> String
forall b a. b -> (a -> b) -> Maybe a -> b
maybe "" (\ f :: NodeOrEdgeFilter
f -> case NodeOrEdgeFilter
f of
OpenCons -> "OpenCons"
OpenGoals -> "Goal") Maybe NodeOrEdgeFilter
m
String -> ShowS
forall a. [a] -> [a] -> [a]
++ String -> (Bool -> String) -> Maybe Bool -> String
forall b a. b -> (a -> b) -> Maybe a -> b
maybe "NodesOrEdges"
(\ b :: Bool
b -> if Bool
b then "Nodes" else "Edges") Maybe Bool
n
ReqFile -> "File"
ReqAxm b :: Bool
b -> if Bool
b then "Axioms" else "Goals"
ReqNumber -> "Number"
ReqNothing -> ""
ReqUnknown -> ""
data CmdlChannel = CmdlChannel
{ CmdlChannel -> String
chName :: String
, CmdlChannel -> CmdlChannelType
chType :: CmdlChannelType
, CmdlChannel -> Handle
chHandler :: Handle
, CmdlChannel -> Maybe CmdlSocket
chSocket :: Maybe CmdlSocket
, CmdlChannel -> CmdlChannelProperties
chProperties :: CmdlChannelProperties }
data CmdlChannelType =
ChSocket
| ChFile
| ChStdin
| ChStdout
data CmdlChannelProperties =
ChRead
| ChWrite
| ChReadWrite
data CmdlSocket = CmdlSocket
{ CmdlSocket -> Socket
socketHandler :: Socket
, CmdlSocket -> String
socketHostName :: HostName
, CmdlSocket -> PortNumber
socketPortNumber :: PortNumber }
data CmdlListAction =
ActionSet
| ActionSetAll
| ActionDel
| ActionDelAll
| ActionAdd
data CmdlMessage = CmdlMessage
{ CmdlMessage -> String
outputMsg :: String
, CmdlMessage -> String
warningMsg :: String
, CmdlMessage -> String
errorMsg :: String }
emptyCmdlMessage :: CmdlMessage
emptyCmdlMessage :: CmdlMessage
emptyCmdlMessage = CmdlMessage :: String -> String -> String -> CmdlMessage
CmdlMessage
{ errorMsg :: String
errorMsg = []
, outputMsg :: String
outputMsg = []
, warningMsg :: String
warningMsg = [] }