Safe Haskell | Safe |
---|---|

Language | Haskell2010 |

Space-efficient stacks with amortized \( O(\log n) \) operations. These directly use an underlying array-based implementation, without doing any special optimization for the very top of the stack.

# Documentation

A stack.

pattern Empty :: Stack a | A bidirectional pattern synonym for the empty stack. |

pattern (:<) :: a -> Stack a -> Stack a infixr 5 | A bidirectional pattern synonym for working with the front of a stack. |

## Instances

Functor Stack Source # | |

Foldable Stack Source # | |

Defined in Data.CompactSequence.Stack.Simple.Internal fold :: Monoid m => Stack m -> 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 # elem :: Eq a => a -> Stack a -> Bool # maximum :: Ord a => Stack a -> a # minimum :: Ord a => Stack a -> a # | |

Traversable Stack Source # | |

IsList (Stack a) Source # | |

Eq a => Eq (Stack a) Source # | |

Ord a => Ord (Stack a) Source # | |

Defined in Data.CompactSequence.Stack.Simple.Internal | |

Show a => Show (Stack a) Source # | |

Semigroup (Stack a) Source # | |

Monoid (Stack a) Source # | |

type Item (Stack a) Source # | |

Defined in Data.CompactSequence.Stack.Simple.Internal |

cons :: a -> Stack a -> Stack a infixr 5 Source #

Push an element onto the front of a stack.

\( O(\log n) \)

uncons :: Stack a -> Maybe (a, Stack a) Source #

Pop an element off the front of a stack.

Accessing the first element is \( O(1) \). Accessing the rest is \( O(\log n) \).

take :: Int -> Stack a -> Stack a Source #

Take up to the given number of elements from the front of a stack to form a new stack. \( O(\min (k, n)) \), where \( k \) is the integer argument and \( n \) is the size of the stack.