{-# LANGUAGE GADTs #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeOperators #-}
module Control.State.Transition.Simple (
applySTSIndifferently,
applySTS,
module Extended,
) where
import Control.Monad.Identity (Identity (..))
import Control.State.Transition.Extended as Extended hiding (applySTS, applySTSIndifferently)
import qualified Control.State.Transition.Extended as X
import Data.Bifunctor (Bifunctor (..))
import Data.Foldable (Foldable (..))
import Data.List.NonEmpty (NonEmpty)
applySTSIndifferently ::
forall s rtype.
(STS s, RuleTypeRep rtype, Identity ~ BaseM s) =>
RuleContext rtype s ->
(State s, [PredicateFailure s])
applySTSIndifferently :: forall s (rtype :: RuleType).
(STS s, RuleTypeRep rtype, Identity ~ BaseM s) =>
RuleContext rtype s -> (State s, [PredicateFailure s])
applySTSIndifferently RuleContext rtype s
ctx = (Seq (PredicateFailure s) -> [PredicateFailure s])
-> (State s, Seq (PredicateFailure s))
-> (State s, [PredicateFailure s])
forall b c a. (b -> c) -> (a, b) -> (a, c)
forall (p :: * -> * -> *) b c a.
Bifunctor p =>
(b -> c) -> p a b -> p a c
second Seq (PredicateFailure s) -> [PredicateFailure s]
forall a. Seq a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList ((State s, Seq (PredicateFailure s))
-> (State s, [PredicateFailure s]))
-> (Identity (State s, Seq (PredicateFailure s))
-> (State s, Seq (PredicateFailure s)))
-> Identity (State s, Seq (PredicateFailure s))
-> (State s, [PredicateFailure s])
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Identity (State s, Seq (PredicateFailure s))
-> (State s, Seq (PredicateFailure s))
forall a. Identity a -> a
runIdentity (Identity (State s, Seq (PredicateFailure s))
-> (State s, [PredicateFailure s]))
-> Identity (State s, Seq (PredicateFailure s))
-> (State s, [PredicateFailure s])
forall a b. (a -> b) -> a -> b
$ RuleContext rtype s -> Identity (State s, Seq (PredicateFailure s))
forall s (m :: * -> *) (rtype :: RuleType).
(STS s, RuleTypeRep rtype, m ~ BaseM s) =>
RuleContext rtype s -> m (State s, Seq (PredicateFailure s))
X.applySTSIndifferently RuleContext rtype s
ctx
applySTS ::
forall s rtype.
(STS s, RuleTypeRep rtype, BaseM s ~ Identity) =>
RuleContext rtype s ->
Either (NonEmpty (PredicateFailure s)) (State s)
applySTS :: forall s (rtype :: RuleType).
(STS s, RuleTypeRep rtype, BaseM s ~ Identity) =>
RuleContext rtype s
-> Either (NonEmpty (PredicateFailure s)) (State s)
applySTS RuleContext rtype s
ctx = Identity (Either (NonEmpty (PredicateFailure s)) (State s))
-> Either (NonEmpty (PredicateFailure s)) (State s)
forall a. Identity a -> a
runIdentity (Identity (Either (NonEmpty (PredicateFailure s)) (State s))
-> Either (NonEmpty (PredicateFailure s)) (State s))
-> Identity (Either (NonEmpty (PredicateFailure s)) (State s))
-> Either (NonEmpty (PredicateFailure s)) (State s)
forall a b. (a -> b) -> a -> b
$ RuleContext rtype s
-> Identity (Either (NonEmpty (PredicateFailure s)) (State s))
forall s (m :: * -> *) (rtype :: RuleType).
(STS s, RuleTypeRep rtype, m ~ BaseM s) =>
RuleContext rtype s
-> m (Either (NonEmpty (PredicateFailure s)) (State s))
X.applySTS RuleContext rtype s
ctx