Commit 7f82c14b authored by Mike Ledger's avatar Mike Ledger

fix intersection/difference

parent 59bb9832
......@@ -64,16 +64,16 @@ output opts = case unHelpful (outfile opts) of
-- | select the combining algorithm
combine :: Ord k => Options -> [Map.Map k a] -> Map.Map k a
combine opts = case unHelpful (op opts) of
Just Intersection -> foldr Map.intersection Map.empty
Just Difference -> foldr Map.difference Map.empty
Just Intersection -> foldr1 Map.intersection
Just Difference -> foldr1 Map.difference
_union -> Map.unions
main :: IO ()
main = do
opts@Options{..} <- getRecord "Map-like operations on csv files"
-- write infiles as maps
inmaps <- runResourceT $ mapM
runResourceT $
-- write infiles as maps
mapM
(fmap (Map.fromList . S.fst')
. S.toList
. S.effects
......@@ -81,13 +81,11 @@ main = do
. S.map (either (const (Left ())) toRow)
. decode opts
. B.readFile)
(unHelpful infiles)
-- write output
runResourceT
. output opts
(unHelpful infiles) >>=
-- write output
output opts
. Csv.encode
-- TODO: add header
. mapM_ (\(k, vs) -> S.yield (k:vs))
. mapM_ (S.yield . uncurry (:))
. Map.toList
$ combine opts inmaps
. combine opts
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment