fsmActions-0.4.4: Finite state machines and FSM actions

Safe HaskellNone

Data.FsmActions.IO

Description

High-level input/output interface for finite state machines.

This module allows one to load and save FSMs, where the format to be used may be either explicitly specified, or guessed according to the filename's extension.

Synopsis

Documentation

data FsmIO Source

Known FSM I/O formats.

Constructors

FsmActionMatrices

ActionMatrix format: use loadActionMxFsm and saveActionMxFsm; filename extensions: actions, actionspec, actionmxs, actionmatrices, fsmactions.

FsmEdges

FsmEdges format: use loadFsmEdges and saveFsmEdges; filename extensions: edges, fsmedges, graph, mathematica.

FsmMatrix

FsmMatrix format: use loadFsmMx and saveFsmMx; filename extensions: mx, matrix, fsmmx, fsmmatrix, fsm.

fsmFormats :: FilePath -> [FsmIO]Source

Given a path, return a list of all FsmIO formats, with guesses (according to the file extension) at the front.

loadFsm :: FilePath -> [FsmIO] -> IO (Either FsmError (FSM String))Source

Read an FSM from a file. If the user specifies any FsmIO formats, try each of those in turn; otherwise, try every format known, using the filename extension to guess which to try first.

The returned value is either the resultant FSM, or the error message produced by trying to load it with the _first_ format (so in the case of guessing formats, if the guess is wrong and the file is corrupt, you might get an unhelpful error message).

saveFsm :: FSM String -> FilePath -> Maybe FsmIO -> IO ()Source

Save an FSM to a file. If the user specifies an FsmIO format, it is used; otherwise, it is guessed from the filename extension (and failing that, the first guess, ie FsmActionMatrices, is used).