automaton-1.4: Effectful streams and automata in initial encoding
Safe HaskellSafe-Inferred
LanguageHaskell2010

Data.Automaton.Trans.State

Description

Handle a global StateT layer in an Automaton.

A global state can be hidden by an automaton by making it an internal state.

This module is based on the strict state monad Strict, so when combining it with other modules such as mtl's, the strict version has to be included, i.e. Strict instead of State or Lazy.

Synopsis

Documentation

stateS :: (Functor m, Monad m) => Automaton m (s, a) (s, b) -> Automaton (StateT s m) a b Source #

Convert from explicit states to the StateT monad transformer.

The original automaton is interpreted to take a state as input and return the updated state as output.

This is the opposite of runStateS.

runStateS :: (Functor m, Monad m) => Automaton (StateT s m) a b -> Automaton m (s, a) (s, b) Source #

Make the state transition in StateT explicit as Automaton inputs and outputs.

This is the opposite of stateS.

runStateS_ Source #

Arguments

:: (Functor m, Monad m) 
=> Automaton (StateT s m) a b

An automaton with a global state effect

-> s

The initial global state

-> Automaton m a (s, b) 

Convert global state to internal state of an Automaton.

The current state is output on every step.

runStateS__ :: (Functor m, Monad m) => Automaton (StateT s m) a b -> s -> Automaton m a b Source #

Like runStateS_, but don't output the current state.