motor-diagrams: Generate state diagrams from Motor FSM typeclasses

[ control, library, mpl ] [ Propose Tags ]

Generate state diagrams from Motor FSM typeclasses.


[Skip to Readme]
Versions 0.2.0.0, 0.3.0
Change log CHANGELOG.md
Dependencies base (>=4.9 && <5), motor, 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 Sat May 19 11:49:55 UTC 2018
Distributions NixOS:0.3.0
Downloads 216 total (29 in the last 30 days)
Rating (no votes yet) [estimated by rule of succession]
Your Rating
  • λ
  • λ
  • λ
Status Docs uploaded by user [build log]
All reported builds failed as of 2018-05-19 [all 3 reports]
Hackage Matrix CI

Modules

[Index]

Downloads

Maintainer's Corner

For package maintainers and hackage trustees


Readme for motor-diagrams-0.3.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.