-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Sequence optimized for monoidal construction and folding -- -- Data structure intended for accumulating a sequence of elements for -- later traversal or folding. Useful for implementing all kinds of -- builders on top. -- -- The benchmarks show that for the described use-case it is on average 2 -- times faster than DList and Seq, is on par with list -- when you always prepend elements and is exponentially faster than list -- when you append. @package acc @version 0.2 module Acc.NeAcc -- | Non-empty accumulator. -- -- Relates to Acc the same way as NonEmpty to list. data NeAcc a module Acc -- | Data structure intended for accumulating a sequence of elements for -- later traversal or folding. Useful for implementing all kinds of -- builders on top. -- -- Appending and prepending is always <math>. -- -- To produce a single element Acc use pure. To produce a -- multielement Acc use fromList. To combine use -- <|> or <> and other Alternative and -- Monoid-related utils. To extract elements use Foldable -- API. -- -- The benchmarks show that for the described use-case this -- data-structure is on average 2 times faster than DList and -- Seq, is on par with list when you always prepend elements and -- is exponentially faster than list when you append. -- -- Internally it is implemented as a simple binary tree with all -- functions optimized to use tail recursion, ensuring that you don't get -- stack overflow. data Acc a -- | Prepend an element. cons :: a -> Acc a -> Acc a -- | Append an element. snoc :: a -> Acc a -> Acc a -- | Extract the first element. -- -- The produced accumulator will lack the extracted element and will have -- the underlying tree rebalanced towards the beginning. This means that -- calling uncons on it will be <math> and unsnoc -- will be <math>. uncons :: Acc a -> Maybe (a, Acc a) -- | Convert to non empty list if it's not empty. toNonEmpty :: Acc a -> Maybe (NonEmpty a) -- | Convert to non empty acc if it's not empty. toNeAcc :: Acc a -> Maybe (NeAcc a) -- | Enumerate in range, inclusively. enumFromTo :: (Enum a, Ord a) => a -> a -> Acc a instance GHC.Base.Functor Acc.Acc instance Control.DeepSeq.NFData a => Control.DeepSeq.NFData (Acc.Acc a) instance Control.DeepSeq.NFData1 Acc.Acc instance Data.Foldable.Foldable Acc.Acc instance Data.Traversable.Traversable Acc.Acc instance GHC.Base.Applicative Acc.Acc instance GHC.Base.Alternative Acc.Acc instance GHC.Base.Semigroup (Acc.Acc a) instance GHC.Base.Monoid (Acc.Acc a) instance GHC.Exts.IsList (Acc.Acc a) instance GHC.Show.Show a => GHC.Show.Show (Acc.Acc a)