simple-parser-0.8.2: Simple parser combinators

SimpleParser.Stack

Synopsis

# Documentation

newtype Stack a Source #

A stack supporting O(1) push, top, and bottom. Behind the newtype, a "push" onto the stack is implemented as "snoc", therefore fold/traverse goes from bottom of stack (most generic label) to top (most specific label).

Constructors

 Stack FieldsunStack :: Seq a

#### Instances

Instances details
 Source # Instance detailsDefined in SimpleParser.Stack Methodsfmap :: (a -> b) -> Stack a -> Stack b #(<\$) :: a -> Stack b -> Stack a # Source # Instance detailsDefined in SimpleParser.Stack Methodsfold :: Monoid m => Stack m -> m #foldMap :: Monoid m => (a -> m) -> Stack a -> m #foldMap' :: Monoid m => (a -> m) -> Stack a -> m #foldr :: (a -> b -> b) -> b -> Stack a -> b #foldr' :: (a -> b -> b) -> b -> Stack a -> b #foldl :: (b -> a -> b) -> b -> Stack a -> b #foldl' :: (b -> a -> b) -> b -> Stack a -> b #foldr1 :: (a -> a -> a) -> Stack a -> a #foldl1 :: (a -> a -> a) -> Stack a -> a #toList :: Stack a -> [a] #null :: Stack a -> Bool #length :: Stack a -> Int #elem :: Eq a => a -> Stack a -> Bool #maximum :: Ord a => Stack a -> a #minimum :: Ord a => Stack a -> a #sum :: Num a => Stack a -> a #product :: Num a => Stack a -> a # Source # Instance detailsDefined in SimpleParser.Stack Methodstraverse :: Applicative f => (a -> f b) -> Stack a -> f (Stack b) #sequenceA :: Applicative f => Stack (f a) -> f (Stack a) #mapM :: Monad m => (a -> m b) -> Stack a -> m (Stack b) #sequence :: Monad m => Stack (m a) -> m (Stack a) # Eq a => Eq (Stack a) Source # Instance detailsDefined in SimpleParser.Stack Methods(==) :: Stack a -> Stack a -> Bool #(/=) :: Stack a -> Stack a -> Bool # Show a => Show (Stack a) Source # Instance detailsDefined in SimpleParser.Stack MethodsshowsPrec :: Int -> Stack a -> ShowS #show :: Stack a -> String #showList :: [Stack a] -> ShowS #

Easy constructor for the empty stack

pushStack :: a -> Stack a -> Stack a Source #

Pushes a an element onto a Stack

topStack :: Stack a -> Maybe a Source #

Returns the top element of the stack (most recently pushed).

bottomStack :: Stack a -> Maybe a Source #

Returns the bottom element of the stack (least recently pushed).

bottomUpStack :: (a -> Maybe b) -> Stack a -> Seq b Source #

Selects elements from the bottom of the stack to the top.