# Control.Applicative.PhantomState: exported symbols usage examples

## Symbols

- changeState Collapse [-]Found in Data.BinaryList from the package binary-list
runState $ replicateA n $ StateT $ \xs -> pure $ case xs of (h:t) -> (h,t ) _ -> (e,[]) -- | /O(n)/. Create a list from the elements of a binary list matching a given -- condition. toListFilter :: (a -> Bool) -> BinList a -> [a] {-# INLINE toListFilter #-} toListFilter c = foldr (\x -> if c x then (x:) else id) [] -- | /O(n)/. Create a list extracting a sublist of elements from a binary list. toListSegment :: Int -> Int -> BinList a -> [a] {-# INLINE toListSegment #-} toListSegment s e xs = runPhantomState (traverseSegment (changeState . (:)) s e xs) [] -- | Apply an applicative action to every element in a segment of a binary list, from left to right. traverseSegment :: Applicative f => (a -> f ()) -> Int -> Int -> BinList a -> f () {-# INLINE traverseSegment #-} traverseSegment f s e xs

runPhantomState Collapse [-]Found in Data.BinaryList from the package binary-listrunState $ replicateA n $ StateT $ \xs -> pure $ case xs of (h:t) -> (h,t ) _ -> (e,[]) -- | /O(n)/. Create a list from the elements of a binary list matching a given -- condition. toListFilter :: (a -> Bool) -> BinList a -> [a] {-# INLINE toListFilter #-} toListFilter c = foldr (\x -> if c x then (x:) else id) [] -- | /O(n)/. Create a list extracting a sublist of elements from a binary list. toListSegment :: Int -> Int -> BinList a -> [a] {-# INLINE toListSegment #-} toListSegment s e xs = runPhantomState (traverseSegment (changeState . (:)) s e xs) [] -- | Apply an applicative action to every element in a segment of a binary list, from left to right. traverseSegment :: Applicative f => (a -> f ()) -> Int -> Int -> BinList a -> f () {-# INLINE traverseSegment #-} traverseSegment f s e xs