packages feed

motor 0.3.0 → 0.4.0

raw patch · 7 files changed

+25/−21 lines, 7 filesdep ~row-typesPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: row-types

API changes (from Hackage documentation)

- Motor.FSM.Class: instance (GHC.TypeLits.KnownSymbol n, n ~ n') => GHC.OverloadedLabels.IsLabel n (Motor.FSM.Class.Name n')
+ Motor.FSM: infix 6 !-
+ Motor.FSM: infixl 6 !-->
+ Motor.FSM: infixr 5 :=
+ Motor.FSM: type family FromActions (as :: [ActionMapping]) (rs :: Row *) (c :: Constraint) :: (Row *, Constraint)
+ Motor.FSM.Class: instance (GHC.TypeLits.KnownSymbol n, n Data.Type.Equality.~ n') => GHC.OverloadedLabels.IsLabel n (Motor.FSM.Class.Name n')
+ Motor.FSM.Sugar: infix 6 !-
+ Motor.FSM.Sugar: infixl 6 !-->
+ Motor.FSM.Sugar: infixr 5 :=
+ Motor.FSM.Sugar: type family FromActions (as :: [ActionMapping]) (rs :: Row *) (c :: Constraint) :: (Row *, Constraint)
- Motor.FSM: enter :: (MonadFSM m, HasType n a r, Modify n b r ~ r') => Name n -> b -> m r r' ()
+ Motor.FSM: enter :: (MonadFSM m, r' ~ ((n .== b) .// r)) => Name n -> b -> m r r' ()
- Motor.FSM.Class: enter :: (MonadFSM m, HasType n a r, Modify n b r ~ r') => Name n -> b -> m r r' ()
+ Motor.FSM.Class: enter :: (MonadFSM m, r' ~ ((n .== b) .// r)) => Name n -> b -> m r r' ()

Files

CHANGELOG.md view
@@ -1,3 +1,6 @@+* 0.4.0 (pending)+  - Use row-types 0.3.0 or higher, and the `Overwrite` construct+    rather than `Modify` * 0.3.0   - Use row-types instead of CTRex.   - Rename `:->` operator to `:=`.
examples/Door.hs view
@@ -100,8 +100,8 @@     ( Door m     -- TODO: Can these constraints be added to the Sugar module     -- automatically?-    , Modify n (State m Open) c ~ o-    , Modify n (State m Closed) o ~ c+    , ((n .== State m Open) .// c) ~ o+    , ((n .== State m Closed) .// o) ~ c     , (o .! n) ~ State m Open     , (c .! n) ~ State m Closed     , (o .- n) ~ (c .- n)
motor.cabal view
@@ -1,5 +1,5 @@ name:                motor-version:             0.3.0+version:             0.4.0 synopsis:   Type-safe effectful state machines in Haskell description:@@ -35,7 +35,7 @@                      , indexed                      , indexed-extras                      , reflection-                     , row-types+                     , row-types >= 0.3.0                      , template-haskell >= 2.11.1.0   hs-source-dirs:      src   default-language:    Haskell2010
src/Motor/FSM.hs view
@@ -1,10 +1,10 @@-{-# LANGUAGE DataKinds                  #-}-{-# LANGUAGE FlexibleContexts           #-}-{-# LANGUAGE FlexibleInstances          #-}-{-# LANGUAGE PolyKinds                  #-}-{-# LANGUAGE ScopedTypeVariables        #-}-{-# LANGUAGE TypeFamilies               #-}-{-# LANGUAGE TypeOperators              #-}+{-# LANGUAGE DataKinds           #-}+{-# LANGUAGE FlexibleContexts    #-}+{-# LANGUAGE FlexibleInstances   #-}+{-# LANGUAGE PolyKinds           #-}+{-# LANGUAGE ScopedTypeVariables #-}+{-# LANGUAGE TypeFamilies        #-}+{-# LANGUAGE TypeOperators       #-} {- | /Motor/ is an experimental Haskell library for building    finite-state machines with type-safe transitions and effects. It    draws inspiration from the Idris@@ -58,10 +58,10 @@   , module Control.Monad.Indexed   ) where -import           Control.Monad.IO.Class import           Control.Monad.Indexed import           Control.Monad.Indexed.State import           Control.Monad.Indexed.Trans+import           Control.Monad.IO.Class import           Data.Functor.Identity       (runIdentity) import           Data.Row.Records @@ -127,7 +127,7 @@   update (Name :: Name n) f = FSM (imodify $ \s -> runIdentity (focus lbl (pure . f) s))     where       lbl = Label :: Label n-  enter (Name :: Name n) x = FSM (imodify $ \s -> runIdentity (focus lbl (const (pure x)) s))+  enter (Name :: Name n) x = FSM (imodify ((lbl .== x) .//))     where       lbl = Label :: Label n   call (FSM ma) = FSM (ilift (fst <$> runIxStateT ma empty))
src/Motor/FSM/Class.hs view
@@ -36,8 +36,9 @@   -- | Deletes an existing resource named by its 'Name'.   delete :: Name n -> m r (r .- n) ()   -- | Replaces the state of an existing resource named by its 'Name'.-  enter ::-       (HasType n a r, Modify n b r ~ r')+  enter+    :: ( r' ~ (n .== b .// r)+       )     => Name n     -> b     -> m r r' ()
src/Motor/FSM/Sugar.hs view
@@ -59,10 +59,10 @@                             , (r .! n) ~ a                             )   FromActions ((n ':= 'To a b) ': ts) r c =-    FromActions ts (Modify n b r) ( c-                                  , (r .! n) ~ a-                                  , (Modify n b r .! n) ~ b-                                  )+    FromActions ts ((n .== b) .// r) ( c+                                     , (r .! n) ~ a+                                     , (((n .== b) .// r) .! n) ~ b+                                     )   FromActions ((n ':= 'Remain a) ': ts) r c =     FromActions ts r (c, (r .! n) ~ a) 
test/Motor/FSMSpec.hs view
@@ -20,10 +20,10 @@ n2 :: Name "n2" n2 = Name -s1s2 :: MonadFSM m => Name n -> m r (Modify n S2 r) ()+s1s2 :: MonadFSM m => Name n -> m r ((n .== S2) .// r) () s1s2 s = enter s S2 -s2s1 :: MonadFSM m => Name n -> m r (Modify n S1 r) ()+s2s1 :: MonadFSM m => Name n -> m r ((n .== S1) .// r) () s2s1 s = enter s S1