motor-diagrams: Generate state diagrams from Motor FSM typeclasses

This is a package candidate release! Here you can preview how this package release will appear once published to the main package index (which can be accomplished via the 'maintain' link below). Please note that once a package has been published to the main package index it cannot be undone! Please consult the package uploading documentation for more information.

[maintain] [Publish]

Generate state diagrams from Motor FSM typeclasses.


[Skip to Readme]

Properties

Versions 0.2.0.0, 0.3.0, 0.4.0, 0.4.0
Change log CHANGELOG.md
Dependencies base (>=4.9 && <5), motor (>=0.4.0), motor-reflection, template-haskell (>=2.11.1.0), text [details]
License MPL-2.0
Copyright Oskar Wickström
Author Oskar Wickström
Maintainer oskar.wickstrom@gmail.com
Category Control
Source repo head: git clone https://github.com/owickstrom/motor
Uploaded by owickstrom at 2019-06-28T05:57:00Z

Modules

[Index] [Quick Jump]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees


Readme for motor-diagrams-0.4.0

[back to package description]

motor-diagrams

Generate state diagrams from Motor FSM typeclasses.

This package is experimental!

Example

Game state diagram

Usage

First, use reflectEvents on your FSM typeclass to obtain a value-level representation:

data Open
data Closed

class MonadFSM m => Door (m :: Row * -> Row * -> * -> *) where
  type State m :: * -> *
  initial
    :: Name n
    -> Actions m '[n !+ State m Open] r ()
  close
    :: Name n
    -> Actions m '[n :-> State m Open !--> State m Closed] r ()
  open
    :: Name n
    -> Actions m '[n :-> State m Closed !--> State m Open] r ()
  end
    :: Name n
    -> Actions m '[n !- State m Closed] r ()

reflectEvents ''Door "doorEvents"

Then, use Motor.FSM.Diagram.renderPlantUmlToFile to render it as a PlantUML state diagram:

main :: IO ()
main =
  renderPlantUmlToFile
    "door.uml.txt"
    doorEvents

Or, use the Template Haskell wrapper Motor.FSM.Diagram.TH.renderPlantUmlToFile to write the file when compiling the module (this requires the reflection to happen in another module):

$(renderPlantUmlToFile
    "door.uml.txt"
    doorEvents)

Last, render in your format of choice using the PlantUML JAR file:

java -jar plantuml.jar -tpng door.uml.txt -o door.png

For an example how to automate the last step with Make, see this Makefile.

License

Mozilla Public License Version 2.0, see LICENSE file in each package.