Wrap filter type more

This commit is contained in:
Filip Gralinski 2020-05-13 08:19:52 +02:00
parent 6f6c96969d
commit 015053ec87
2 changed files with 12 additions and 3 deletions

View File

@ -377,7 +377,7 @@ checkAndGetDataSources forceInput gevalSpec = do
challengeDataSourceExpected = expectedSource,
challengeDataSourceSelector = mSelector,
challengeDataSourcePreprocess = preprocess,
challengeDataSourceFilter = Filter Nothing,
challengeDataSourceFilter = noFilter,
challengeDataSourceInHeader = mInHeader,
challengeDataSourceOutHeader = mOutHeader }
@ -502,7 +502,7 @@ gevalCoreOnSingleLines metric preprocess inpDecoder inpLine expDecoder expLine o
then preprocess
else id
lsSpec = LineSourcesSpecification {
lineSourcesFilter = Filter Nothing,
lineSourcesFilter = noFilter,
lineSourcesInputSource = singleLineAsLineSource inpLine inpDecoder preprocess,
lineSourcesExpectedSource = singleLineAsLineSource expLine expDecoder outputPreprocess,
lineSourcesOutputSource = singleLineAsLineSource outLine outDecoder outputPreprocess }

View File

@ -1,7 +1,9 @@
module GEval.DataSource
(ChallengeDataSource(..),
DataSource(..),
Filter(..))
Filter,
noFilter,
applyFilter)
where
import Data.Text
@ -12,6 +14,13 @@ import GEval.Selector
newtype Filter = Filter (Maybe (Text -> Bool))
noFilter :: Filter
noFilter = Filter Nothing
applyFilter :: Filter -> (Text, (Text, Text)) -> Bool
applyFilter (Filter Nothing) _ = True
applyFilter (Filter (Just fun)) (inp, (exp, out)) = fun inp
-- | This type specifies the way the challenge data (input and
-- expected data, but not outputs) flow into evaluation.
--