motor-reflection: Reflect on Motor FSM typeclasses to obtain runtime representations

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]

Reflect on Motor FSM typeclasses to obtain runtime representations.


[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), 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:03Z

Modules

[Index]

Downloads

Maintainer's Corner

For package maintainers and hackage trustees


Readme for motor-reflection-0.4.0

[back to package description]

motor-reflection

Reflect on typeclasses following Motor FSM conventions, using Template Haskell.

This package is experimental!

Usage

First, you need to import the reflection module and the Event type:

import           Motor.FSM.Reflection
import           Motor.FSM.Reflection.Event (Event)

Given that your FSM typeclass follows Motor's conventions, you can reflect to get a list of events:

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"

The last line, using reflectEvents, will define doorEvents :: [Motor.FSM.Reflection.Event.Event] at the top-level.

Conventions

These conventions may be relaxed in the future. This package is new and experimental.

License

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