pipes-ordered-zip: merge two ordered Producers into a new Producer

[ bioinformatics, bsd3, library ] [ Propose Tags ] [ Report a vulnerability ]

provides a simple function to merge two Pipes-Producers into a new Producer that yields pairs of values of the original producers, but using Maybes to indicate values that are only present in the first, second or both producers. Useful to perform Left-Joins, Right-Joins and Inner-Joins on the fly using Haskell Pipes.


[Skip to Readme]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

Versions [RSS] 1.0.0.1, 1.0.1, 1.1.0, 1.2.0, 1.2.1
Change log Changelog.md
Dependencies base (>=4.7 && <5), pipes (>=4.3.14), pipes-safe (>=2.3.2) [details]
License BSD-3-Clause
Copyright 2019 Stephan Schiffels
Author Stephan Schiffels
Maintainer stephan_schiffels@mac.com
Category Bioinformatics
Home page https://github.com/githubuser/pipes-ordered-zip#readme
Uploaded by stephan_schiffels at 2021-02-25T10:46:39Z
Distributions LTSHaskell:1.2.1, NixOS:1.2.1, Stackage:1.2.1
Downloads 2066 total (14 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2021-02-25 [all 1 reports]

Readme for pipes-ordered-zip-1.2.1

[back to package description]

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]