From 2783a5bed8320b31415bd1cba5171b92a3e6e869 Mon Sep 17 00:00:00 2001 From: Filip Gralinski Date: Tue, 26 Oct 2021 08:31:36 +0200 Subject: [PATCH] Fix handling p

with line-by-line mode --- src/GEval/Common.hs | 7 ++++++- src/GEval/Core.hs | 7 +++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/GEval/Common.hs b/src/GEval/Common.hs index 18ea048..d8901cd 100644 --- a/src/GEval/Common.hs +++ b/src/GEval/Common.hs @@ -7,10 +7,15 @@ import Data.Text.Read as TR import Data.Word import Control.Exception -import Data.Attoparsec.Text +import Data.Attoparsec.Text hiding (Done) data SourceItem a = Got a | Wrong String | Done +instance Functor SourceItem where + fmap f (Got a) = Got (f a) + fmap _ (Wrong s) = Wrong s + fmap _ Done = Done + type MetricValue = Double data GraphSeries = GraphSeries [(Double, Double)] diff --git a/src/GEval/Core.hs b/src/GEval/Core.hs index 114daf9..d393a77 100644 --- a/src/GEval/Core.hs +++ b/src/GEval/Core.hs @@ -1163,8 +1163,11 @@ threeLineSource (WithInput theFilter inputLineSource expectedLineSource outLineS <*> (ZipSource $ getZipSource $ (,) <$> ZipSource (linesAsItems expectedLineSource) <*> ZipSource (linesAsItems outLineSource))) - .| (CC.filter (applyFilterToSourceItems $ generalizedFilterFilter theFilter)) - .| (CC.map (\(x, (y,z)) -> WrappedParsedRecordWithInput x y z)) + .| (CC.map (\(x, (y,z)) -> TargetRecord (fmap RawItemTarget x) (fmap RawItemTarget y) (fmap RawItemTarget z))) + .| (CC.filter (applyFilter $ generalizedFilterFilter theFilter)) + .| topperConduit (generalizedFilterTopper theFilter) + .| (CC.map (\(TargetRecord x y z) -> WrappedParsedRecordWithInput (unwrap x) (unwrap y) (unwrap z))) + where unwrap = fmap (\(RawItemTarget x) -> x) averageC :: MonadResource m => ConduitT Double Void m Double averageC = getZipSink