matterhorn-50200.17.0: Terminal client for the Mattermost chat system
Safe HaskellNone
LanguageHaskell2010

Matterhorn.Types.NonemptyStack

Synopsis

Documentation

data NonemptyStack a Source #

A stack that always has at least one value on it.

Instances

Instances details
Show a => Show (NonemptyStack a) Source # 
Instance details

Defined in Matterhorn.Types.NonemptyStack

newStack :: a -> NonemptyStack a Source #

Make a new stack with the specified value at the bottom.

push :: a -> NonemptyStack a -> NonemptyStack a Source #

Push the specified value on to the stack.

pop :: NonemptyStack a -> (NonemptyStack a, Maybe a) Source #

Pop the top value from the stack. If a value could be popped, return the new stack and the value that was popped. Otherwise return the stack unmodified with Nothing to indicate that nothing was popped.

top :: NonemptyStack a -> a Source #

Return the value on the top of the stack. Always succeeds since the stack is guaranteed to be non-empty.

stackToList :: NonemptyStack a -> [a] Source #

Return the stack as a list, topmost element first.