Giter VIP home page Giter VIP logo

motor's Introduction

Motor: Type-safe effectful state machines in Haskell

Motor is an experimental Haskell library for building finite-state machines with type-safe transitions and effects. It draws inspiration from the Idris ST library.

Usage

See the Motor module documentation on Hackage for detailed usage.

Packages

  • motor — the core of Motor.
  • motor-reflection — reflect on typeclasses following Motor FSM conventions.
  • motor-diagrams — use value-representations from motor-reflection to generate diagrams.

Examples

License

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

motor's People

Contributors

owickstrom avatar vaibhavsagar avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

motor's Issues

Consider dropping indexed-extra dependency?

I'm interested in playing with this library, but the fact that stack.yaml has to have allow-newer set to accommodate indexed-extra is kind of a no-go for larger projects.

I'd think it might be possible to wholesale copy over the necessary modules from indexed-extra and have them be hidden modules as a temporary stopgap.

I can't resolve dependency issues

I'm using stack and have tried resolving with lts-7.24, lts-9.10, lts-9.11, lts-9.12, and the latest, lts-9.13

To recreate, I did

  1. stack new ...
  2. add motor to .cabal
  3. stack solver

And I get something like this:

$ stack solver
Using configuration file: stack.yaml
Using cabal packages:
- motor-experiment.cabal

Using resolver: lts-7.24
Using compiler: ghc-8.0.1
Asking cabal to calculate a build plan...
Trying with packages from lts-7.24 as hard constraints...
Attempt failed.

>>>> Cabal errors begin
cabal: Could not resolve dependencies:
trying: motor-0.2.0.0 (dependency of motor-experiment-0.1.0.0)
next goal: template-haskell (dependency of motor-0.2.0.0)
rejecting: template-haskell-2.11.0.0/installed-2.1... (conflict: motor =>
template-haskell>=2.11.1.0)
rejecting: template-haskell-2.12.0.0, template-haskell-2.11.1.0 (constraint
from main config /tmp/cabal-solver15965/cabal.config requires ==2.11.0.0)
rejecting: template-haskell-2.11.0.0 (conflict: motor =>
template-haskell>=2.11.1.0)
rejecting: template-haskell-2.10.0.0, template-haskell-2.9.0.0,
template-haskell-2.8.0.0, template-haskell-2.7.0.0, template-haskell-2.6.0.0,
template-haskell-2.5.0.0, template-haskell-2.4.0.1, template-haskell-2.4.0.0,
template-haskell-2.3.0.1, template-haskell-2.3.0.0, template-haskell-2.2.0.0
(constraint from main config /tmp/cabal-solver15965/cabal.config requires
==2.11.0.0)
Dependency tree exhaustively searched.
<<<< Cabal errors end

Could not parse cabal-install errors:

>>>> Cabal errors begin
cabal: Could not resolve dependencies:
trying: motor-0.2.0.0 (dependency of motor-experiment-0.1.0.0)
next goal: template-haskell (dependency of motor-0.2.0.0)
rejecting: template-haskell-2.11.0.0/installed-2.1... (conflict: motor =>
template-haskell>=2.11.1.0)
rejecting: template-haskell-2.12.0.0, template-haskell-2.11.1.0 (constraint
from main config /tmp/cabal-solver15965/cabal.config requires ==2.11.0.0)
rejecting: template-haskell-2.11.0.0 (conflict: motor =>
template-haskell>=2.11.1.0)
rejecting: template-haskell-2.10.0.0, template-haskell-2.9.0.0,
template-haskell-2.8.0.0, template-haskell-2.7.0.0, template-haskell-2.6.0.0,
template-haskell-2.5.0.0, template-haskell-2.4.0.1, template-haskell-2.4.0.0,
template-haskell-2.3.0.1, template-haskell-2.3.0.0, template-haskell-2.2.0.0
(constraint from main config /tmp/cabal-solver15965/cabal.config requires
==2.11.0.0)
Dependency tree exhaustively searched.
<<<< Cabal errors end

CallStack (from HasCallStack):
  error, called at src/Stack/Solver.hs:144:25 in stack-1.5.1-8L0HpUwgvNa7pLuInyRw8N:Stack.Solver

I've never had to build up haskell dependency-resolution-skills, because normally, things just work, but... thought I'd mention this here because I love Idris, and I love the Motor presentation, and would love to give Motor a shot!

Result-based state changes

It would be nice to be able to encode multiple outcomes of an operation, i.e. one that can cause different state changes depending on the result. For instance, if an operation throws an error, it might not change the state of the resource/state machine, but only do that on success.

One idea was to introduce a special operation in Motor where you supply a "record of continuations", each covering a specific case. This would basically be like pattern matching with case on the various possible outcomes. The type of the multi-outcome operation would use a row type to encode the various cases and their result types, and the record of continuations would have a type aligning with that.

Another twist on this, as suggested by Joe Kachmar, was to use generic-lens and a variation of the above to handle each case, using some polymorphic prism.

Any interest and ideas on this topic would be welcome!

Have 'call' operate on subset of resources

Instead of a type call :: m Empty Empty a -> m r r a, it would be nice to accept a subset of r as input to the inner computation, and perhaps have its output be a subset of the result output. Not sure if this would work with CTRex, though.

reflectEvents example does not work

Trying to use reflectEvents with the provided example (Door) results in the rather illuminating type error:

src/Door.hs:52:1: error:
    Unsupported type:ForallT [KindedTV n_6989586621679026880 (ConT GHC.Types.Symbol),KindedTV r_6989586621679026881 (AppT (ConT Data.Row.Internal.Row) StarT)] [] (AppT (AppT ArrowT (AppT (ConT Motor.FSM.Class.Name) (VarT n_6989586621679026880))) (AppT (AppT (AppT (AppT (ConT Motor.FSM.Sugar.Actions) (VarT m_6989586621679026856)) (AppT (AppT PromotedConsT (AppT (AppT (ConT Motor.FSM.Sugar.!+) (VarT n_6989586621679026880)) (AppT (AppT (ConT Main.State) (VarT m_6989586621679026856)) (ConT Main.Closed)))) (SigT PromotedNilT (AppT ListT (ConT Motor.FSM.Sugar.ActionMapping))))) (VarT r_6989586621679026881)) (TupleT 0)))
   |
52 | reflectEvents ''Door "doorEvents"
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

I'm using GHC 8.10.2.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.