motor-diagrams: Generate state diagrams from Motor FSM typeclasses

[ control, library, mpl ] [ Propose Tags ] [ Report a vulnerability ]

Generate state diagrams from Motor FSM typeclasses.


[Skip to Readme]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

Versions [RSS] 0.2.0.0, 0.3.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:58:57Z
Distributions
Reverse Dependencies 1 direct, 0 indirect [details]
Downloads 1758 total (11 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs uploaded by user
Build status unknown [no reports yet]

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.