Copyright | (c) Eric Mertens 2021 |
---|---|
License | ISC |
Maintainer | emertens@gmail.com |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Documentation
FIFO Queue implementation
pattern Empty :: Queue a | Empty queue
|
pattern (:<|) :: a -> Queue a -> Queue a | Pattern for
|
Instances
Foldable Queue Source # | Fold over elements in the order they would be returned by pop
|
Defined in Advent.Queue fold :: Monoid m => Queue m -> m # foldMap :: Monoid m => (a -> m) -> Queue a -> m # foldMap' :: Monoid m => (a -> m) -> Queue a -> m # foldr :: (a -> b -> b) -> b -> Queue a -> b # foldr' :: (a -> b -> b) -> b -> Queue a -> b # foldl :: (b -> a -> b) -> b -> Queue a -> b # foldl' :: (b -> a -> b) -> b -> Queue a -> b # foldr1 :: (a -> a -> a) -> Queue a -> a # foldl1 :: (a -> a -> a) -> Queue a -> a # elem :: Eq a => a -> Queue a -> Bool # maximum :: Ord a => Queue a -> a # minimum :: Ord a => Queue a -> a # | |
Read a => Read (Queue a) Source # | |
Show a => Show (Queue a) Source # | Renders using
|
(|>) :: Queue a -> a -> Queue a Source #
Add an element to the end of a queue. See: snoc
>>>
fromList "abc" |> 'z'
fromList "abcz"
singleton :: a -> Queue a Source #
Construct a queue from a single element.
>>>
singleton 'a'
fromList "a"
fromList :: [a] -> Queue a Source #
Construct a queue from a list. The head of the list will
be the first element returned by pop
snoc :: a -> Queue a -> Queue a Source #
Add a new element to the end of a queue.
>>>
snoc 'z' (fromList "abc")
fromList "abcz"
pop :: Queue a -> Maybe (a, Queue a) Source #
Remove an element from the front of a queue and a new queue without that element.
>>>
pop (fromList "abc")
Just ('a',fromList "bc")
appendList :: Queue a -> [a] -> Queue a Source #
Append many items onto a queue. The items will pop from the queue in the same order as they are in the given list.
>>>
appendList (fromList "xyz") "abc"
fromList "xyzabc"