module Data.FTCQueue
( FTCQueue
, tsingleton
, (|>)
, snoc
, (><)
, append
, ViewL(..)
, tviewl
) where
data FTCQueue m a b where
Leaf :: (a -> m b) -> FTCQueue m a b
Node :: FTCQueue m a x -> FTCQueue m x b -> FTCQueue m a b
tsingleton :: (a -> m b) -> FTCQueue m a b
tsingleton :: (a -> m b) -> FTCQueue m a b
tsingleton = (a -> m b) -> FTCQueue m a b
forall a (m :: * -> *) b. (a -> m b) -> FTCQueue m a b
Leaf
{-# INLINE tsingleton #-}
(|>) :: FTCQueue m a x -> (x -> m b) -> FTCQueue m a b
FTCQueue m a x
t |> :: FTCQueue m a x -> (x -> m b) -> FTCQueue m a b
|> x -> m b
r = FTCQueue m a x -> FTCQueue m x b -> FTCQueue m a b
forall (m :: * -> *) a x b.
FTCQueue m a x -> FTCQueue m x b -> FTCQueue m a b
Node FTCQueue m a x
t ((x -> m b) -> FTCQueue m x b
forall a (m :: * -> *) b. (a -> m b) -> FTCQueue m a b
Leaf x -> m b
r)
{-# INLINE (|>) #-}
snoc :: FTCQueue m a x -> (x -> m b) -> FTCQueue m a b
snoc :: FTCQueue m a x -> (x -> m b) -> FTCQueue m a b
snoc = FTCQueue m a x -> (x -> m b) -> FTCQueue m a b
forall (m :: * -> *) a x b.
FTCQueue m a x -> (x -> m b) -> FTCQueue m a b
(|>)
{-# INLINE snoc #-}
(><) :: FTCQueue m a x -> FTCQueue m x b -> FTCQueue m a b
FTCQueue m a x
t1 >< :: FTCQueue m a x -> FTCQueue m x b -> FTCQueue m a b
>< FTCQueue m x b
t2 = FTCQueue m a x -> FTCQueue m x b -> FTCQueue m a b
forall (m :: * -> *) a x b.
FTCQueue m a x -> FTCQueue m x b -> FTCQueue m a b
Node FTCQueue m a x
t1 FTCQueue m x b
t2
{-# INLINE (><) #-}
append :: FTCQueue m a x -> FTCQueue m x b -> FTCQueue m a b
append :: FTCQueue m a x -> FTCQueue m x b -> FTCQueue m a b
append = FTCQueue m a x -> FTCQueue m x b -> FTCQueue m a b
forall (m :: * -> *) a x b.
FTCQueue m a x -> FTCQueue m x b -> FTCQueue m a b
(><)
{-# INLINE append #-}
data ViewL m a b where
TOne :: (a -> m b) -> ViewL m a b
(:|) :: (a -> m x) -> FTCQueue m x b -> ViewL m a b
tviewl :: FTCQueue m a b -> ViewL m a b
tviewl :: FTCQueue m a b -> ViewL m a b
tviewl (Leaf a -> m b
r) = (a -> m b) -> ViewL m a b
forall a (m :: * -> *) b. (a -> m b) -> ViewL m a b
TOne a -> m b
r
tviewl (Node FTCQueue m a x
t1 FTCQueue m x b
t2) = FTCQueue m a x -> FTCQueue m x b -> ViewL m a b
forall (m :: * -> *) a x b.
FTCQueue m a x -> FTCQueue m x b -> ViewL m a b
go FTCQueue m a x
t1 FTCQueue m x b
t2
where
go :: FTCQueue m a x -> FTCQueue m x b -> ViewL m a b
go :: FTCQueue m a x -> FTCQueue m x b -> ViewL m a b
go (Leaf a -> m x
r) FTCQueue m x b
tr = a -> m x
r (a -> m x) -> FTCQueue m x b -> ViewL m a b
forall a (m :: * -> *) x b.
(a -> m x) -> FTCQueue m x b -> ViewL m a b
:| FTCQueue m x b
tr
go (Node FTCQueue m a x
tl1 FTCQueue m x x
tl2) FTCQueue m x b
tr = FTCQueue m a x -> FTCQueue m x b -> ViewL m a b
forall (m :: * -> *) a x b.
FTCQueue m a x -> FTCQueue m x b -> ViewL m a b
go FTCQueue m a x
tl1 (FTCQueue m x x -> FTCQueue m x b -> FTCQueue m x b
forall (m :: * -> *) a x b.
FTCQueue m a x -> FTCQueue m x b -> FTCQueue m a b
Node FTCQueue m x x
tl2 FTCQueue m x b
tr)