BSD-3-Clause licensed by Stephan Schiffels
Maintained by [email protected]
This version can be pinned in stack with:pipes-ordered-zip-1.2.1@sha256:1bece0cde4315987da28b6a588dd3345dda8f61bb6894e4e4c9c3cd3a4646746,1453

Module documentation for 1.2.1

Depends on 3 packages(full list with versions):
Used by 1 package in lts-22.37(full list with versions):

pipes-ordered-zip

A function to tie together two sorted Haskell Iterators (Producers from the pipes library).

Example:

import Pipes (runEffect, (>->), each)
import qualified Pipes.Prelude as P
import Pipes.OrderedZip (orderedZip)

main = do
    let a = each [1,  3,4,  6,8] -- assumed to be ordered
        b = each [  2,3,4,5,  8] -- assumed to be ordered
    let mergedProd = orderedZip compare a b
    _ <- runEffect $ mergedProd >-> P.print
    return ()

prints:

(Just 1,Nothing)
(Nothing,Just 2)
(Just 3,Just 3)
(Just 4,Just 4)
(Nothing,Just 5)
(Just 6,Nothing)
(Just 8,Just 8)

and

import Pipes (runEffect, (>->), each)
import qualified Pipes.Prelude as P
import Pipes.OrderedZip (orderedZipAll)

main = do
    let a = each ([1,  3,4,  6,  8] :: [Int])
        b = each ([  2,3,4,5,    8] :: [Int])
        c = each ([  2,3,  5,  7,8] :: [Int])
        mergedProd = orderedZipAll compare [a, b, c]
    _ <- runEffect $ mergedProd >-> P.print
    return ()

prints

[Just 1,Nothing,Nothing]
[Nothing,Just 2,Just 2]
[Just 3,Just 3,Just 3]
[Just 4,Just 4,Nothing]
[Nothing,Just 5,Just 5]
[Just 6,Nothing,Nothing]
[Nothing,Nothing,Just 7]
[Just 8,Just 8,Just 8]

Changes

  • Version 1.0.0.0: Initial commit with example, tests and haddock

  • Version 1.0.0.1: Added a note that input sequences have to be sorted.

  • V 1.1.0: Added new function to check ordering of incoming pipes