module Conferer.Source.Mapping
(
mkMappingSource
, mkMappingSource'
)
where
import Data.Map (Map)
import qualified Data.Map as Map
import Conferer.Types
mkMappingSource' :: (Key -> Maybe Key) -> SourceCreator -> SourceCreator
mkMappingSource' mapper sourceCreator config = do
configSource <- sourceCreator config
return $ Source
{ getKeyInSource = \k -> do
case mapper k of
Just newKey -> getKeyInSource configSource newKey
Nothing -> return Nothing
}
mkMappingSource :: Map Key Key -> SourceCreator -> SourceCreator
mkMappingSource configMap configSource =
mkMappingSource' (`Map.lookup` configMap) configSource