-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | A type class for sequences and various sequence data structures.
--
-- A type class for sequences and various sequence data structures.
@package sequence
@version 0.9.3
-- | A type class for sequences.
--
-- See the package type-aligned for a generalization of this type class
-- sequences.
module Data.SequenceClass
-- | A type class for (finite) sequences
--
-- Minimal complete defention: empty and singleton and
-- (viewl or viewr) and (>< or |> or
-- <|)
--
-- Instances should satisfy the following laws:
--
-- Monoid laws: > empty >< x == x > x >< empty == x
-- > (x >y)= x(y< z)
--
-- Observation laws: > viewl (singleton e >< s) == e :< s
-- > viewl empty == EmptyL
--
-- The behaviour of <|,|>, and viewr is
-- implied by the above laws and their default definitions.
class (Functor s, Foldable s) => Sequence s where l |> r = l >< singleton r l <| r = singleton l >< r l >< r = case viewl l of { EmptyL -> r h :< t -> h <| (t >< r) } viewl q = case viewr q of { EmptyR -> EmptyL p :> l -> case viewl p of { EmptyL -> l :< empty h :< t -> h :< (t |> l) } } viewr q = case viewl q of { EmptyL -> EmptyR h :< t -> case viewr t of { EmptyR -> empty :> h p :> l -> (h <| p) :> l } }
empty :: Sequence s => s c
singleton :: Sequence s => c -> s c
(><) :: Sequence s => s c -> s c -> s c
viewl :: Sequence s => s c -> ViewL s c
viewr :: Sequence s => s c -> ViewR s c
(|>) :: Sequence s => s c -> c -> s c
(<|) :: Sequence s => c -> s c -> s c
data ViewL s c
EmptyL :: ViewL s c
(:<) :: c -> s c -> ViewL s c
data ViewR s c
EmptyR :: ViewR s c
(:>) :: s c -> c -> ViewR s c
instance Sequence []
instance Sequence Seq
-- | A sequence, a queue, with amortized constant time: |>, and
-- tviewl.
--
-- A simplified version of Okasaki's implicit recursive slowdown queues.
-- See purely functional data structures by Chris Okasaki section 8.4:
-- Queues based on implicit recursive slowdown
module Data.Sequence.Queue
data Queue a
instance Sequence Queue
instance Foldable Queue
instance Functor Queue
instance Functor B
instance Functor P
-- | A sequence, a queue, with worst case constant time: |>, and
-- tviewl.
--
-- Based on: "Simple and Efficient Purely Functional Queues and Deques",
-- Chris Okasaki, Journal of Functional Programming 1995
module Data.Sequence.FastQueue
data FastQueue a
instance Sequence FastQueue
instance Foldable FastQueue
instance Functor FastQueue
-- | A purely functional catenable queue representation with that turns
-- takes a purely functional queue and turns in it into a catenable
-- queue, i.e. with the same complexity for >< as for
-- |> Based on Purely functional data structures by Chris
-- Okasaki section 7.2: Catenable lists
module Data.Sequence.ToCatQueue
-- | The catenable queue type. The first type argument is the type of the
-- queue we use (|>)
data ToCatQueue q a
instance Sequence q => Sequence (ToCatQueue q)
instance Sequence q => Foldable (ToCatQueue q)
instance Functor q => Functor (ToCatQueue q)
-- | A sequence, a catanable queue, with worst case constant time:
-- ><, |>, <| and tviewl.
module Data.Sequence.FastCatQueue
type FastTCQueue = ToCatQueue FastQueue