diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Main.hs | 13 | ||||
-rw-r--r-- | src/Network.hs | 33 | ||||
-rw-r--r-- | src/Parser.hs | 2 | ||||
-rw-r--r-- | src/Test.hs | 13 |
4 files changed, 37 insertions, 24 deletions
diff --git a/src/Main.hs b/src/Main.hs index 81da048..02d690f 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -30,23 +30,12 @@ import System.Posix.Signals import System.Process import GDB +import Network import Output import Parser import Process import Test -data Network = Network - { netNodes :: MVar [Node] - , netProcesses :: MVar [Process] - , netDir :: FilePath - } - -data Node = Node - { nodeName :: NodeName - , nodeNetwork :: Network - , nodeDir :: FilePath - } - data Options = Options { optDefaultTool :: String , optProcTools :: [(ProcName, String)] diff --git a/src/Network.hs b/src/Network.hs new file mode 100644 index 0000000..633db16 --- /dev/null +++ b/src/Network.hs @@ -0,0 +1,33 @@ +module Network ( + Network(..), + Node(..), + NodeName(..), textNodeName, unpackNodeName, +) where + +import Control.Concurrent + +import Data.Text (Text) +import Data.Text qualified as T + +import Process + +data Network = Network + { netNodes :: MVar [Node] + , netProcesses :: MVar [Process] + , netDir :: FilePath + } + +data Node = Node + { nodeName :: NodeName + , nodeNetwork :: Network + , nodeDir :: FilePath + } + +newtype NodeName = NodeName Text + deriving (Eq, Ord) + +textNodeName :: NodeName -> Text +textNodeName (NodeName name) = name + +unpackNodeName :: NodeName -> String +unpackNodeName (NodeName tname) = T.unpack tname diff --git a/src/Parser.hs b/src/Parser.hs index db98fc1..7534eaa 100644 --- a/src/Parser.hs +++ b/src/Parser.hs @@ -27,6 +27,8 @@ import qualified Text.Megaparsec.Char.Lexer as L import System.Exit +import Network (NodeName(..)) +import Process (ProcName(..)) import Test type TestParser = ParsecT Void TestStream (State TestParserState) diff --git a/src/Test.hs b/src/Test.hs index 8db7552..41649ef 100644 --- a/src/Test.hs +++ b/src/Test.hs @@ -3,9 +3,6 @@ module Test ( TestStep(..), SourceLine(..), - ProcName(..), textProcName, unpackProcName, - NodeName(..), textNodeName, unpackNodeName, - MonadEval(..), VarName(..), textVarName, unpackVarName, ExprType(..), @@ -25,6 +22,7 @@ import Data.Typeable import Text.Regex.TDFA import Text.Regex.TDFA.Text +import Network import Process import Util @@ -42,15 +40,6 @@ data TestStep = forall a. ExprType a => Let SourceLine VarName (Expr a) [TestSte newtype SourceLine = SourceLine Text -newtype NodeName = NodeName Text - deriving (Eq, Ord) - -textNodeName :: NodeName -> Text -textNodeName (NodeName name) = name - -unpackNodeName :: NodeName -> String -unpackNodeName (NodeName tname) = T.unpack tname - class MonadFail m => MonadEval m where lookupVar :: VarName -> m SomeVarValue |