úÎH‘E¤,      !"#$%&'()*+/Error monad for reading matrices from strings. +Errors when reading matrices from strings. Explanatory message Offending value #An  8 is well-formed if all its actions are the same length, ? and none of its actions contain destinations which are out of  range. Some .s contain out-of-range (negative or too-high) > destinations. Carries a sorted list of all such actions and  their corresponding symbols. Lengths 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  .  ; is well-formed. (Carries an empty list: this is a slight < wart, as no cargo is necessary; unfortunately, fixing that ; would require use of a GADT here, which seems excessive.) 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 . With current  implementation, is just [0..n] for some n (or empty). Compute the alphabet of an  . Look up a symbol's  in an    Check if an   is well-formed or not. ,;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. " Test if an  is deterministic or not. #Compute whether an   is deterministic or not. $ Normalise an  , i.e. normalise all its Actions. %!  !"#$%! $% !"#!    !"#$% ./0 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   1 whose actions are read from matrices in each of  the paths using ' (and 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. -readFSMFromMxFiles :: Ord sy => [(sy, String)] -> IO (FSM sy) '2Read an action matrix from a specified file; uses  (! to interpret the file contents. (>Given a bytestring we expect to contain a serialisation of an - adjacency matrix, compute the corresponding .  The serialisation format for an  on an  n-state   is as follows: there are n , (newline-separated) lines, each containing n (comma-separated) 0s D or 1s. No other characters are allowed (not even whitespace), and C it is an error for any of the rows to contain anything other than  n cells. (Note that n) is not specified, but inferred from the ! number of lines in the string). 1(Turn a string into an adjacency matrix. 234 Given an 0, compute the corresponding  . 5 Given an /!, compute the list of indices of D cells in the row which are set (i.e. which represent transitions). &'(&'(&'()@Parse an FsmMatrix-formatted FSM held in a file, by reading the  file and calling *. *=Parse an FsmMatrix-formatted FSM held in a string. Includes + normalisation and well-formedness checks. 67+/Pretty-print a string FSM in FsmMatrix format. 8)*+)*+)*+9         !"#$%&'()*+,-./012345678fsmActions-0.1Data.FsmActions.ErrorData.FsmActionsData.FsmActions.ActionMatrixData.FsmActions.FsmMatrix ReadMxMonadMxErrormsgvalue WellFormed BadActions BadLengthsWordFSMunFSMActiondestinationSetsDestinationSet destinationsStatestatesalphabet fsmAction isWellFormedmkAction mkDActionappend actionLookupaction actionEquivdestinationSetdestinationEquiv fsmIdentity isDActionisDFSM normalisenormaliseActionreadFSMFromMxFilesreadAdjMxFromFilereadAdjMxFromString parseFsmFileparseFsmStringprintFsmMatrixallSame appendAtStateAdjacencyMatrixCellAdjacencyMatrixRowAdjacencyMatrix splitMxString readMxRow readMxCellparseActionMatrixparseActionMatrixRow fsmParser interpretFsm ppFsmMatrix