From e6f8e2eeb66880950bd35fd82d439d87e7fa6bf5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roman=20Smr=C5=BE?= Date: Wed, 28 Sep 2022 13:31:49 +0200 Subject: Generic record member selection expression --- src/Network.hs | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/Network.hs') diff --git a/src/Network.hs b/src/Network.hs index 633db16..5872d13 100644 --- a/src/Network.hs +++ b/src/Network.hs @@ -4,12 +4,14 @@ module Network ( NodeName(..), textNodeName, unpackNodeName, ) where +import Control.Arrow import Control.Concurrent import Data.Text (Text) import Data.Text qualified as T import Process +import Test data Network = Network { netNodes :: MVar [Node] @@ -19,6 +21,7 @@ data Network = Network data Node = Node { nodeName :: NodeName + , nodeIp :: Text , nodeNetwork :: Network , nodeDir :: FilePath } @@ -31,3 +34,13 @@ textNodeName (NodeName name) = name unpackNodeName :: NodeName -> String unpackNodeName (NodeName tname) = T.unpack tname + + +instance ExprType Node where + textExprType _ = T.pack "node" + textExprValue n = T.pack "n:" <> textNodeName (nodeName n) + emptyVarValue = Node (NodeName T.empty) T.empty undefined undefined + + recordMembers = map (first T.pack) + [ ("ip", RecordSelector $ nodeIp) + ] -- cgit v1.2.3