fsmActions-0.4.1: Finite state machines and FSM actionsSource codeContentsIndex

Serialisation/deserialisation of FSMs and Actions as binary adjacency matrices.

An Action may be represented as an adjacency matrix of 0s and 1s. The rows and columns of the matrix correspond to states of an FSM: a 1 in a cell indicates that the Action causes a transition from the 'row' state to the 'column' state. If any of the rows in the matrix contain more than one 1, the corresponding Action and FSM will be nondeterministic.

An ActionSpecFile is a list of (symbol string, path to ActionMatrix file) pairs. Its syntax is as follows:

  • Symbols, and paths, should all be enclosed in double quotes (with the nice side-effect that spaces are thus allowed).
  • A symbol/path pair is separated by whitespace.
  • The list of symbol/path pairs is delimited by semicolons (and optional whitespace). A trailing semicolon is optional.
  • Line comments, starting with -- (as in Haskell), are allowed anywhere whitespace is allowed.
loadActionMxFsm :: FilePath -> IO (FSM String)
saveActionMxFsm :: FSM String -> FilePath -> [(String, FilePath)] -> IO ()
parseFsmActionMxFiles :: (Ord sy, Show sy) => [(sy, FilePath)] -> IO (FSM sy)
parseFsmActionMxs :: (Ord sy, Show sy) => [(sy, String)] -> ReadFsmMonad (FSM sy)
parseActionMx :: String -> ReadFsmMonad Action
printFsmActionMx :: FSM String -> [(String, FilePath)] -> (String, [(FilePath, String)])
printActionMx :: Action -> String
loadActionMxFsm :: FilePath -> IO (FSM String)Source
Load an FSM from action matrices, given a path to an ActionSpec file.
saveActionMxFsm :: FSM String -> FilePath -> [(String, FilePath)] -> IO ()Source
Save an FSM to an ActionSpec file (whose path is specified) and a set of action matrices (whose paths may be optionally specified using a (label, path) association list).
parseFsmActionMxFiles :: (Ord sy, Show sy) => [(sy, FilePath)] -> IO (FSM sy)Source
Given a (symbol, path) association list, compute an FSM whose actions are read from action matrices in the specified paths, and associated with their corresponding symbols.
parseFsmActionMxs :: (Ord sy, Show sy) => [(sy, String)] -> ReadFsmMonad (FSM sy)Source

Given a (symbol, ActionMatrix string) association list, parse the strings and construct an FSM. Includes normalisation and well-formedness checks. Parse errors in individual action strings result in an error here (ReadFsmMonad is in the Either monad).

Note that if the same symbol appears multiple times, only one instance will appear in the FSM; the choice of which appears is not defined.

parseActionMx :: String -> ReadFsmMonad ActionSource
Parse an action matrix string, and turn it into an Action.
printFsmActionMx :: FSM String -> [(String, FilePath)] -> (String, [(FilePath, String)])Source
Pretty-print a string FSM into an ActionSpec string and an (ActionMatrix path, ActionMatrix string) association list. (The paths will be interpreted relative to the ActionSpec's location.) Filenames (per action label) may be specified by providing a (label, path) association list; whenever a lookup in that list fails, a default is computed from the label.
printActionMx :: Action -> StringSource
Pretty-print an action in action matrix format.
Produced by Haddock version 2.6.0