From 8865c86aa904243ae91a598327e9dc1768ae8f3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roman=20Smr=C5=BE?= Date: Tue, 27 Sep 2022 22:59:18 +0200 Subject: Separate Network module --- src/Network.hs | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 src/Network.hs (limited to 'src/Network.hs') 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 -- cgit v1.2.3