modelling-tasks-0.0.0.1
Safe HaskellSafe-Inferred
LanguageHaskell2010

Modelling.PetriNet.Parser

Description

A module for parsing Petri Alloy instances into Haskell representations defined by the Types module. The instances contain valid and invalid Petri nets that is why these are parsed into types as Net which allow representing some invalid representations of graphs which are similar to Petri nets.

Synopsis

Documentation

asSingleton :: MonadThrow m => Set b -> m b Source #

Convert a singleton Set into its single value. Returns a Left error message if the Set is empty or contains more than one single element.

convertPetri Source #

Arguments

:: MonadThrow m 
=> String

the name of the flow set

-> String

the name of the token set

-> AlloyInstance

the Petri net AlloyInstance

-> m Petri 

Given the name of a flow set and a token set the given alloy instance is parsed to a Net graph and a Petri is returned if the instance is indeed a valid Petri net (after applying petriLikeToPetri).

netToGr :: (Monad m, Net p n, Ord a) => p n a -> m (Gr (a, Maybe Int) Int) Source #

Convert a Net into a Gr enabling to draw it using graphviz.

parseChange :: MonadThrow m => AlloyInstance -> m (PetriChange Object) Source #

Parses a PetriChange given an AlloyInstance. On error a Left error message will be returned.

parseNet Source #

Arguments

:: (MonadThrow m, Net p n) 
=> String

the name of the flow set

-> String

the name of the token set

-> AlloyInstance

the Petri net AlloyInstance

-> m (p n Object) 

Parse a Net graph from an AlloyInstance given the instances flow and token set names.

parseRenamedNet :: (MonadThrow m, Net p n) => String -> String -> AlloyInstance -> m (p n String) Source #

Parse a Net graph from an AlloyInstance given the instances flow and token set names. And return an already renamed Petri net.

simpleNameMap :: (Net p n, Ord a) => p n a -> Bimap a String Source #

Retrieve a simple naming map from a given Net. The newly created names for naming every PetriNode of the Net are unique for each individually PetriNode. Furthermore, each place node's names prefix is a s, while each transition node's name is preceded by a t. These prefixes are followed by numbers starting at 1 and reaching to the number of place nodes and transition nodes respectively.

simpleRename :: Object -> Either String String Source #

Transform an Object into a String by replacing the prefix. Returns Either:

  • an error message if no matching prefix was found
  • or the resulting String

simpleRenameWith :: (MonadThrow m, Net p n, Ord a) => p n a -> a -> m String Source #

Transform a given value into a String by replacing it according to the simpleNameMap retrieved by the given Net.