fix some warnings

This commit is contained in:
Filip Graliński 2018-08-02 08:29:52 +02:00
parent 4b3a4fa665
commit cd30d88998

View File

@ -278,7 +278,7 @@ isEmptyFile path = do
return ((fileSize stat) == 0) return ((fileSize stat) == 0)
data LineSource m = LineSource (Source m Text) SourceSpec Word32 data LineSource m = LineSource (ConduitT () Text m ()) SourceSpec Word32
geval :: GEvalSpecification -> IO [(SourceSpec, [MetricValue])] geval :: GEvalSpecification -> IO [(SourceSpec, [MetricValue])]
geval gevalSpec = do geval gevalSpec = do
@ -595,7 +595,7 @@ gevalCoreWithoutInput :: (MonadUnliftIO m, MonadThrow m, MonadIO m) =>
((a, b) -> c) -> -- ^ function which combines parsed values into a single value ((a, b) -> c) -> -- ^ function which combines parsed values into a single value
-- (will be launched for each item, e.g. an error/cost function -- (will be launched for each item, e.g. an error/cost function
-- could be calculated here) -- could be calculated here)
(Sink c (ResourceT m) d) -> -- ^ a Conduit which aggregates all the combined values into (ConduitT c Void (ResourceT m) d) -> -- ^ a Conduit which aggregates all the combined values into
-- a "total" value -- a "total" value
(d -> Double) -> -- ^ function to transform the "total" value into the final score (d -> Double) -> -- ^ function to transform the "total" value into the final score
LineSource (ResourceT m) -> -- ^ source to read the expected output LineSource (ResourceT m) -> -- ^ source to read the expected output
@ -607,7 +607,7 @@ gevalCoreWithoutInput expParser outParser itemStep aggregator finalStep expected
trans :: ((a, b) -> c) -> ParsedRecord (WithoutInput m a b) -> c trans :: ((a, b) -> c) -> ParsedRecord (WithoutInput m a b) -> c
trans step (ParsedRecordWithoutInput x y) = step (x, y) trans step (ParsedRecordWithoutInput x y) = step (x, y)
gevalCore''' :: (MonadUnliftIO m, MonadThrow m, MonadIO m) => ParserSpec (WithoutInput m a b) -> ((Word32, (a, b)) -> c) -> (Sink c (ResourceT m) d) -> (d -> Double) -> WithoutInput m a b -> m (MetricValue) gevalCore''' :: (MonadUnliftIO m, MonadThrow m, MonadIO m) => ParserSpec (WithoutInput m a b) -> ((Word32, (a, b)) -> c) -> (ConduitT c Void (ResourceT m) d) -> (d -> Double) -> WithoutInput m a b -> m (MetricValue)
gevalCore''' parserSpec itemStep aggregator finalStep context = gevalCore''' parserSpec itemStep aggregator finalStep context =
gevalCoreGeneralized' parserSpec (trans itemStep) aggregator finalStep context gevalCoreGeneralized' parserSpec (trans itemStep) aggregator finalStep context
where where
@ -622,14 +622,14 @@ gevalCoreGeneralized :: (EvaluationContext ctxt m, MonadUnliftIO m, MonadThrow m
ParserSpec ctxt -> -- ^ parsers to parse data ParserSpec ctxt -> -- ^ parsers to parse data
(ParsedRecord ctxt -> c) -> -- ^ function to go from the parsed value into (ParsedRecord ctxt -> c) -> -- ^ function to go from the parsed value into
-- some "local" score calculated for each line (item) -- some "local" score calculated for each line (item)
(Sink c (ResourceT m) d) -> -- ^ a Conduit to aggregate score into a "total" (ConduitT c Void (ResourceT m) d) -> -- ^ a Conduit to aggregate score into a "total"
(d -> Double) -> -- ^ function to transform the "total" value into the final score (d -> Double) -> -- ^ function to transform the "total" value into the final score
ctxt -> -- ^ "context", i.e. 2 or 3 sources needed to operate ctxt -> -- ^ "context", i.e. 2 or 3 sources needed to operate
m (MetricValue) m (MetricValue)
gevalCoreGeneralized parserSpec itemStep aggregator finalStep context = gevalCoreGeneralized parserSpec itemStep aggregator finalStep context =
gevalCoreGeneralized' parserSpec (skipLineNumber itemStep) aggregator finalStep context gevalCoreGeneralized' parserSpec (skipLineNumber itemStep) aggregator finalStep context
gevalCoreGeneralized' :: forall m ctxt c d . (EvaluationContext ctxt m, MonadUnliftIO m, MonadThrow m, MonadIO m) => ParserSpec ctxt -> ((Word32, ParsedRecord ctxt) -> c) -> (Sink c (ResourceT m) d) -> (d -> Double) -> ctxt -> m (MetricValue) gevalCoreGeneralized' :: forall m ctxt c d . (EvaluationContext ctxt m, MonadUnliftIO m, MonadThrow m, MonadIO m) => ParserSpec ctxt -> ((Word32, ParsedRecord ctxt) -> c) -> (ConduitT c Void (ResourceT m) d) -> (d -> Double) -> ctxt -> m (MetricValue)
gevalCoreGeneralized' parserSpec itemStep aggregator finalStep context = do gevalCoreGeneralized' parserSpec itemStep aggregator finalStep context = do
v <- runResourceT $ v <- runResourceT $
(((getZipSource $ (,) (((getZipSource $ (,)
@ -646,7 +646,7 @@ class EvaluationContext ctxt m where
data ParserSpec ctxt :: * data ParserSpec ctxt :: *
data WrappedParsedRecord ctxt :: * data WrappedParsedRecord ctxt :: *
data ParsedRecord ctxt :: * data ParsedRecord ctxt :: *
recordSource :: ctxt -> ParserSpec ctxt -> Source (ResourceT m) (WrappedParsedRecord ctxt) recordSource :: ctxt -> ParserSpec ctxt -> ConduitT () (WrappedParsedRecord ctxt) (ResourceT m) ()
getFirstLineNo :: Proxy m -> ctxt -> Word32 getFirstLineNo :: Proxy m -> ctxt -> Word32
getExpectedSource :: ctxt -> SourceSpec getExpectedSource :: ctxt -> SourceSpec
getOutSource :: ctxt -> SourceSpec getOutSource :: ctxt -> SourceSpec
@ -718,13 +718,13 @@ instance (MonadUnliftIO m, MonadIO m, MonadThrow m) => EvaluationContext (WithIn
averageC :: MonadResource m => Sink Double m Double averageC :: MonadResource m => ConduitT Double Void m Double
averageC = getZipSink averageC = getZipSink
$ (\total count -> total / fromIntegral count) $ (\total count -> total / fromIntegral count)
<$> ZipSink CC.sum <$> ZipSink CC.sum
<*> ZipSink CC.length <*> ZipSink CC.length
items :: MonadResource m => LineSource m -> (Text -> Either String a) -> Source m (SourceItem a) items :: MonadResource m => LineSource m -> (Text -> Either String a) -> ConduitT () (SourceItem a) m ()
items (LineSource lineSource _ _) parser = items (LineSource lineSource _ _) parser =
(lineSource =$= CL.map (toItem . parser)) >> yield Done (lineSource =$= CL.map (toItem . parser)) >> yield Done
where toItem (Right x) = Got x where toItem (Right x) = Got x