summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoman Smrž <roman.smrz@seznam.cz>2022-09-27 22:59:18 +0200
committerRoman Smrž <roman.smrz@seznam.cz>2022-09-27 22:59:18 +0200
commit8865c86aa904243ae91a598327e9dc1768ae8f3a (patch)
tree4f9aa0bf0a95281feaf08adf12f6054f9f0193dc
parent4b35f08baa69eefd667d220020f469e591c5b0cf (diff)
Separate Network module
-rw-r--r--erebos-tester.cabal1
-rw-r--r--src/Main.hs13
-rw-r--r--src/Network.hs33
-rw-r--r--src/Parser.hs2
-rw-r--r--src/Test.hs13
5 files changed, 38 insertions, 24 deletions
diff --git a/erebos-tester.cabal b/erebos-tester.cabal
index 37d316b..4c16133 100644
--- a/erebos-tester.cabal
+++ b/erebos-tester.cabal
@@ -34,6 +34,7 @@ executable erebos-tester-core
ghc-options: -Wall -threaded
main-is: Main.hs
other-modules: GDB
+ Network
Output
Parser
Process
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