úÎ QLN"6      !"#$%&'()*+,-./012345/Error monad for reading matrices from strings. +Errors when reading matrices from strings. Explanatory message Offending value Words are lists of symbols. <Finite state machine whose nodes are labelled with type sy. Actions are lists of DestinationSets, indexed by source  . #Destination sets are just lists of s. )States are integers, counting from zero. "Compute the list of states of the . Only really meaningful  if the FSM's well-formedness is not  BadLengths. With current  implementation, is just [0..n] for some n (or empty). Compute the alphabet of an . Look up a symbol's    in an  ;Build an action given a nested list of destination states. ABuild a deterministic action given a list of destination states.  Append two   s, ie compute the    corresponding to 6 the application of the first followed by the second.  Compute the   reached by following some     from some .  Compute the    for some  over some  . The word & might contain symbols outside the FSM's alphabet, so the result  could be Nothing.  Test if two 's are action-equivalent over some FSM.  Compute the   for some  at some  of  an 1. The word might contain symbols outside the FSM's C alphabet, or the state might be out of range, so the result could  be Nothing.  Test if two %s are destination-equivalent at some  of  an . -Compute the identity action for a given FSM. 9Compute the identity action for a given number of states  Test if an    is deterministic or not. Compute whether an  is deterministic or not.  Normalise an , i.e. normalise all its Actions.   !    !    !6 This module'5s internal represenation of adjacency matrices is as E nested lists of booleans. These are only ever used as intermediate = data structures, and should not be generated or manipulated ; directly. If you want to work with actions, use the Core    , type. If you want serialised matrices for E storage or transmission, convert them to strings of 0s and 1s using  the functions in this module. "1Given a list of (symbol, path) pairs, compute an  - whose actions are read from action matrices = in the specified paths, associated with their corresponding  symbols. >Note that if the same symbol appears multiple times, only one  instance will appear in the ; the choice of which  appears is not defined. #BRead an action matrix from a specified file, and parse it into an    . $3Parse an action matrix string, and turn it into an    . 7&Parse an action matrix from a string. ?The string being parsed should contain newline-separated rows, E where each row contains comma-separated cells, where each cell is a + 0 or a 1. Trailing newlines are ignored. 8 Given an 6, compute the corresponding    . 9 Given an :', compute the list of indices of cells > in the row which are set (i.e. which represent transitions). %0Pretty-print an action in action matrix format. "#$%"#$%"#$%&When converting an  into a graph, do we keep D all self-loops, or only those which are sources of nondeterminism? )3Turn an FSM into an fgl graph with labelled edges. *Compute an FSM'!s strongly-connected components. +Compute an FSM's weakly-connected components. ;@The PatriciaTree instance of Graph is faster, but not generally  useful to us because it doesn'#t allow multiple edges between the 9 same pair of nodes. For SCC checks, however, that doesn' t matter,  so we use it. &'()*+&(')*+&(''()*+,Turn an FSM into a < = , trimming any  self-loops which aren't sources of nondeterminism. ,,,-An 8 is well-formed if all its actions are the same length, B none of its actions contain destinations which are out of range,  and it is not disjoint. . Well-formed. /9The FSM is disconnected, i.e. not even weakly-connected. > Carries a list of its weakly-connected components (each is a  list of s). 0Some   .s contain out-of-range (negative or too-high) > destinations. Carries a sorted list of all such actions and  their corresponding symbols. 1Lengths of Actions in the  don't all match. Carries a  sorted list of (symbol,    length) pairs, one for every  symbol in the alphabet of the . 2 Check if an  is well-formed or not. -./012-10/.2-10/../0123@Parse an FsmMatrix-formatted FSM held in a file, by reading the  file and calling parseFsmString. 4=Parse an FsmMatrix-formatted FSM held in a string. Includes + normalisation and well-formedness checks. 5/Pretty-print a string FSM in FsmMatrix format. 345345345>      !"#$%&'()*+,-./01223456789:;<=>? @ @AfsmActions-0.2.0Data.FsmActions.ErrorData.FsmActionsData.FsmActions.ActionMatrixData.FsmActions.FGLData.FsmActions.GraphVizData.FsmActions.WellFormedData.FsmActions.FsmMatrixgraphviz-2999.0.0.0Data.GraphViz.Types ReadMxMonadMxErrormsgvalueWordFSMunFSMActiondestinationSetsDestinationSet destinationsStatestatesalphabet fsmActionmkAction mkDActionappend actionLookupaction actionEquivdestinationSetdestinationEquiv fsmIdentityidentity isDActionisDFSM normalisenormaliseActionparseFsmActionMxFilesparseActionMxFile parseActionMx printActionMx SelfLoopsTrimKeepfsmToFGL strongCCsweakCCsfsmToDot WellFormed Disconnected BadActions BadLengths isWellFormedparseFsmMxFile parseFsmMx printFsmMx ActionMatrixactionMxParserinterpretActionMxparseActionMxRowActionMatrixRowfsmToPatriciaTreeDotGraph