Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- newtype TrekT s m a = TrekT (LogicT (StateT s m) a)
- type Trek s a = TrekT s Identity a
- select :: Monad m => (s -> a) -> TrekT s m a
- selectEach :: (Monad m, Foldable f) => (s -> f a) -> TrekT s m a
- iter :: Foldable f => f a -> TrekT s m a
- collect :: Monad m => TrekT s m a -> TrekT s m [a]
- mount :: Monad m => (t -> s) -> TrekT s m a -> TrekT t m a
- mountEach :: (Monad m, Foldable f) => (t -> f s) -> TrekT s m a -> TrekT t m a
- with :: Monad m => s -> TrekT s m a -> TrekT t m a
- withEach :: (Monad m, Foldable f) => f s -> TrekT s m a -> TrekT t m a
- evalTrek :: Trek s a -> s -> [a]
- evalTrekT :: Monad m => TrekT s m a -> s -> m [a]
- execTrek :: Trek s a -> s -> s
- execTrekT :: Monad m => TrekT s m a -> s -> m s
- runTrek :: Trek s a -> s -> ([a], s)
- runTrekT :: Monad m => TrekT s m a -> s -> m ([a], s)
- get :: MonadState s m => m s
- gets :: MonadState s m => (s -> a) -> m a
- put :: MonadState s m => s -> m ()
- modify :: MonadState s m => (s -> s) -> m ()
- ask :: MonadReader r m => m r
- asks :: MonadReader r m => (r -> a) -> m a
Types
The Trek Monad Transformer. Implements both MonadReader and MonadState.
Instances
Monad m => MonadState s (TrekT s m) Source # | |
Monad m => MonadReader s (TrekT s m) Source # | |
MonadTrans (TrekT s) Source # | |
Monad (TrekT s m) Source # | |
Functor (TrekT s m) Source # | |
MonadFail (TrekT s m) Source # | |
Applicative (TrekT s m) Source # | |
Alternative (TrekT s m) Source # | |
Semigroup a => Semigroup (TrekT s m a) Source # | |
Monoid a => Monoid (TrekT s m a) Source # | |
Combinators
iter :: Foldable f => f a -> TrekT s m a Source #
Iterate over each of the provided values one at a time.
collect :: Monad m => TrekT s m a -> TrekT s m [a] Source #
Run a full TrekT
block collecting all results into a list
mount :: Monad m => (t -> s) -> TrekT s m a -> TrekT t m a Source #
Run a TrekT
block over a portion of state. All state changes from the block are
discarded.
mountEach :: (Monad m, Foldable f) => (t -> f s) -> TrekT s m a -> TrekT t m a Source #
Like mount
but focuses each of a list of values one at a time.
All state changes from the block are discarded.
with :: Monad m => s -> TrekT s m a -> TrekT t m a Source #
Run a TrekT
block over a piece of state.
All state changes from the block are discarded.
withEach :: (Monad m, Foldable f) => f s -> TrekT s m a -> TrekT t m a Source #
Like with
but focuses each of a list of values one at a time.
All state changes from the block are discarded.
Running Trek
execTrekT :: Monad m => TrekT s m a -> s -> m s Source #
Return the altered state after running a TrekT
.
Re-Exports
get :: MonadState s m => m s #
Return the state from the internals of the monad.
gets :: MonadState s m => (s -> a) -> m a #
Gets specific component of the state, using a projection function supplied.
put :: MonadState s m => s -> m () #
Replace the state inside the monad.
modify :: MonadState s m => (s -> s) -> m () #
Monadic state transformer.
Maps an old state to a new state inside a state monad. The old state is thrown away.
Main> :t modify ((+1) :: Int -> Int) modify (...) :: (MonadState Int a) => a ()
This says that modify (+1)
acts over any
Monad that is a member of the MonadState
class,
with an Int
state.
ask :: MonadReader r m => m r #
Retrieves the monad environment.
:: MonadReader r m | |
=> (r -> a) | The selector function to apply to the environment. |
-> m a |
Retrieves a function of the current environment.