The motor-diagrams package

[ Tags: control, library, mpl ] [ Propose Tags ]

Generate state diagrams from Motor FSM typeclasses.


[Skip to Readme]

Properties

Versions 0.2.0.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 repository head: git clone https://github.com/owickstrom/motor
Uploaded Mon Nov 6 17:40:26 UTC 2017 by owickstrom
Distributions NixOS:0.2.0.0
Downloads 154 total (73 in the last 30 days)
Rating (no votes yet) [estimated by rule of succession]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2017-11-06 [all 1 reports]
Hackage Matrix CI

Modules

[Index]

Downloads

Maintainer's Corner

For package maintainers and hackage trustees


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