Fix handling p<P> with line-by-line mode

This commit is contained in:
Filip Gralinski 2021-10-26 08:31:36 +02:00
parent 40bf850423
commit 2783a5bed8
2 changed files with 11 additions and 3 deletions

View File

@ -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)]

View File

@ -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