{-# options_haddock prune #-}
module Helic.Effect.Agent where
import GHC.TypeLits (KnownSymbol, symbolVal)
import Polysemy.Tagged (Tagged)
import Helic.Data.AgentId (AgentId (AgentId))
import Helic.Data.Event (Event)
data AgentTag =
AgentTag Symbol
data Agent :: Effect where
Update :: Event -> Agent m ()
makeSem ''Agent
type AgentTmux =
'AgentTag "tmux"
type AgentX =
'AgentTag "x"
type AgentNet =
'AgentTag "net"
type Agents =
[
Tagged AgentTmux Agent,
Tagged AgentX Agent,
Tagged AgentNet Agent
]
class AgentName (tag :: AgentTag) where
agentName :: Text
instance (
KnownSymbol s
) => AgentName ('AgentTag s) where
agentName :: Text
agentName =
String -> Text
forall a. ToText a => a -> Text
toText (Proxy s -> String
forall (n :: Symbol) (proxy :: Symbol -> *).
KnownSymbol n =>
proxy n -> String
symbolVal (Proxy s
forall k (t :: k). Proxy t
Proxy @s))
agentIdTmux :: AgentId
agentIdTmux :: AgentId
agentIdTmux =
Text -> AgentId
AgentId Text
"tmux"
agentIdX :: AgentId
agentIdX :: AgentId
agentIdX =
Text -> AgentId
AgentId Text
"x"
agentIdNet :: AgentId
agentIdNet :: AgentId
agentIdNet =
Text -> AgentId
AgentId Text
"net"