module Deque.Strict.State
where
import Deque.Prelude hiding (tail, init, last, head, null, dropWhile, takeWhile, reverse)
import Deque.Strict (Deque)
import qualified Deque.Strict as Deque
import qualified Deque.Prelude as Prelude
map :: MonadState (Deque a) m => (a -> a) -> m ()
map f = modify (fmap f)
prepend :: MonadState (Deque a) m => Deque a -> m ()
prepend deque = modify (deque <>)
append :: MonadState (Deque a) m => Deque a -> m ()
append deque = modify (<> deque)
cons :: MonadState (Deque a) m => a -> m ()
cons a = modify (Deque.cons a)
snoc :: MonadState (Deque a) m => a -> m ()
snoc a = modify (Deque.snoc a)
reverse :: MonadState (Deque a) m => m ()
reverse = modify Deque.reverse
shiftLeft :: MonadState (Deque a) m => m ()
shiftLeft = modify Deque.shiftLeft
shiftRight :: MonadState (Deque a) m => m ()
shiftRight = modify Deque.shiftRight
filter :: MonadState (Deque a) m => (a -> Bool) -> m ()
filter predicate = modify (Deque.filter predicate)
take :: MonadState (Deque a) m => Int -> m ()
take = modify . Deque.take
drop :: MonadState (Deque a) m => Int -> m ()
drop = modify . Deque.drop
takeWhile :: MonadState (Deque a) m => (a -> Bool) -> m ()
takeWhile predicate = modify (Deque.takeWhile predicate)
dropWhile :: MonadState (Deque a) m => (a -> Bool) -> m ()
dropWhile predicate = modify (Deque.dropWhile predicate)
span :: MonadState (Deque a) m => (a -> Bool) -> m (Deque a)
span predicate = state (Deque.span predicate)
uncons :: MonadState (Deque a) m => m (Maybe a)
uncons = state (\ deque -> case Deque.uncons deque of
Nothing -> (Nothing, deque)
Just (a, newDeque) -> (Just a, newDeque))
unsnoc :: MonadState (Deque a) m => m (Maybe a)
unsnoc = state (\ deque -> case Deque.unsnoc deque of
Nothing -> (Nothing, deque)
Just (a, newDeque) -> (Just a, newDeque))
null :: MonadState (Deque a) m => m Bool
null = gets Deque.null
length :: MonadState (Deque a) m => m Int
length = gets Prelude.length
head :: MonadState (Deque a) m => m (Maybe a)
head = gets Deque.head
last :: MonadState (Deque a) m => m (Maybe a)
last = gets Deque.last
tail :: MonadState (Deque a) m => m ()
tail = modify Deque.tail
init :: MonadState (Deque a) m => m ()
init = modify Deque.init