-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | Additional merges and joins for Conduit
--   
--   Please see README.md
@package hw-conduit-merges
@version 0.2.0.0

module HaskellWorks.Data.Conduit.Merge

-- | A result value of joining two sources.
--   
--   When sources are joined, the result value can be a value or it be a
--   leftover on either left or right side in case if one of the streams is
--   ehausted before another.
data JoinResult a v b

-- | Leftover on the left side, the right side is exhausted
LeftoverL :: a -> JoinResult a v b

-- | Result value
JoinValue :: v -> JoinResult a v b

-- | Leftover on the right side, the left side is exhausted
LeftoverR :: b -> JoinResult a v b

-- | Joins sources with the provided merging function. Leftovers are
--   considered valid values and are retuned as a part of a result stream.
--   
--   <pre>
--   import Data.Conduit
--   import Data.Conduit.List as CL
--   
--   -- combining function just sums both values
--   comb :: (Ord a, Num a) =&gt; a -&gt; a -&gt; ([a], [a], [a])
--   comb a b
--     | a &gt; b     = ([a - b], [b], [])
--     | b &gt; a     = ([], [a], [b - a])
--     | otherwise = ([], [a], [])
--   
--   let lst1 = CL.sourceList [1,2,3]
--   let lst2 = CL.sourceList [1,2,3,4,5]
--   runConduit $ joinSources comb lst1 lst2 $$ CL.take 1000
--   
--   [<a>JoinValue</a> 2,<a>JoinValue</a> 4,<a>JoinValue</a> 6,<a>LeftoverR</a> 4,<a>LeftoverR</a> 5]
--   </pre>
joinSources :: Monad m => (a -> b -> ([a], [v], [b])) -> ConduitT () a m () -> ConduitT () b m () -> ConduitT () (JoinResult a v b) m ()
joinResumableSources :: Monad m => (a -> b -> ([a], [v], [b])) -> SealedConduitT () a m () -> SealedConduitT () b m () -> ConduitT () (JoinResult a v b) m ()
instance (GHC.Classes.Eq a, GHC.Classes.Eq v, GHC.Classes.Eq b) => GHC.Classes.Eq (HaskellWorks.Data.Conduit.Merge.JoinResult a v b)
instance (GHC.Show.Show a, GHC.Show.Show v, GHC.Show.Show b) => GHC.Show.Show (HaskellWorks.Data.Conduit.Merge.JoinResult a v b)
