The motor-reflection package

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

Reflect on Motor FSM typeclasses to obtain runtime representations.

[Skip to Readme]


Change log
Dependencies base (>=4.9 && <5), motor, template-haskell (>=, text [details]
License MPL-2.0
Copyright Oskar Wickström
Author Oskar Wickström
Category Control
Source repository head: git clone
Uploaded Mon Nov 6 17:40:19 UTC 2017 by owickstrom
Distributions NixOS:
Downloads 155 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




Maintainer's Corner

For package maintainers and hackage trustees

Readme for motor-reflection-

[back to package description]


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

This package is experimental!


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 :: * -> *
    :: Name n
    -> Actions m '[n !+ State m Open] r ()
    :: Name n
    -> Actions m '[n :-> State m Open !--> State m Closed] r ()
    :: Name n
    -> Actions m '[n :-> State m Closed !--> State m Open] r ()
    :: 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.


  • The typeclass must have an associated type (open type family) called State, parameterized by the instance, with a result of kind * -> *.
  • Each FSM event in the typeclass must have a return type of the Actions type alias, listing the additions, deletions, and transitions of named resources.

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


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