Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

file 30 lines (24 sloc) 0.96 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
module Agent( KP.SiteName, SiteId, KP.InternalState, InternalStateId, BindingState(..), Site, Interface
            , AgentId, AgentNameId, Agent(..), KP.AgentName, nameId, interface, foldInterface
            ) where

import qualified KappaParser as KP
import qualified Data.Map as Map
import qualified Data.Vector as Vec

{- Basic types regarding Kappa agents and some accessor functions.
-}

-- Sites
type SiteId = Int
type InternalStateId = Int
data BindingState = Free | SemiLink | Bound | Unspecified -- WLD = Unspecified
  deriving (Show, Eq)
type Site = (Maybe InternalStateId, BindingState)
type Interface = Map.Map SiteId Site

-- Agents
type AgentId = Int
type AgentNameId = Int
data Agent = Agent AgentNameId Interface
  deriving (Show, Eq)

nameId (Agent agentNameId _) = agentNameId
interface (Agent _ intf) = intf

foldInterface :: (SiteId -> Site -> a -> a) -> a -> Agent -> a
foldInterface f acc (Agent _ intf) = Map.foldrWithKey f acc intf
Something went wrong with that request. Please try again.