Copyright | (c) Lars Brünjes, 2016 |
---|---|
License | MIT |
Maintainer | brunjlar@gmail.com |
Stability | experimental |
Portability | portable |
Safe Haskell | None |
Language | Haskell2010 |
Extensions | GeneralizedNewtypeDeriving |
This module defines the StackT
monad transformer,
which is simply a wrapped state monad whose state is a list.
- data StackT s m a
- pop :: Monad m => StackT s m (Maybe s)
- peek :: Monad m => StackT s m (Maybe s)
- push :: Monad m => s -> StackT s m ()
- runStackT :: StackT s m a -> [s] -> m (a, [s])
- evalStackT :: Monad m => StackT s m a -> [s] -> m a
- execStackT :: Monad m => StackT s m a -> [s] -> m [s]
- type Stack s = StackT s Identity
- runStack :: Stack s a -> [s] -> (a, [s])
- evalStack :: Stack s a -> [s] -> a
- execStack :: Stack s a -> [s] -> [s]
Documentation
A computation of type
has access to a stack of elements of type StackT
s m as
.
pop :: Monad m => StackT s m (Maybe s) Source #
Pops the top element from the stack. Returns Nothing
if the stack is empty.
peek :: Monad m => StackT s m (Maybe s) Source #
Peeks at the top element of the stack. Returns Nothing
if the stack is empty.
evalStackT :: Monad m => StackT s m a -> [s] -> m a Source #
Evaluates a computation in the
monad.StackT
s m