[nlp] simplify types: we just map languages from ini config

parent e250af8a
......@@ -37,21 +37,15 @@ readConfig fp = do
ini <- readIniFile' fp
let val' = val ini iniSection
let m_nlp_en = parseURI $ cs $ val' "EN"
let m_nlp_fr = parseURI $ cs $ val' "FR"
let m_nlp_all = parseURI $ cs $ val' "All"
let m_nlp_keys = filter (\k -> k `notElem` ["EN", "FR", "All"]) $ fromRight [] $ Ini.keys iniSection ini
let m_nlp_keys = filter (\k -> k `notElem` ["All"]) $ fromRight [] $ Ini.keys iniSection ini
let m_nlp_other = listToMaybeAll $ (\k -> (,) k <$> (parseURI $ cs $ val' k)) <$> m_nlp_keys
let mRet = NLPConfig <$> m_nlp_en <*> m_nlp_fr <*> m_nlp_all <*> (Map.fromList <$> m_nlp_other)
let mRet = NLPConfig <$> m_nlp_all <*> (Map.fromList <$> m_nlp_other)
case mRet of
Nothing -> panic $ T.concat [ "Cannot read config file: _nlp_en = "
, T.pack $ show m_nlp_en
, ", _nlp_fr = "
, T.pack $ show m_nlp_fr
, ", _nlp_all = "
Nothing -> panic $ T.concat [ "Cannot read config file: _nlp_all = "
, T.pack $ show m_nlp_all
, ", _nlp_other = "
, T.pack $ show m_nlp_other ]
......
......@@ -21,10 +21,8 @@ import Network.Socket (PortNumber)
import Network.URI (URI)
import Protolude
data NLPConfig = NLPConfig { _nlp_en :: URI
, _nlp_fr :: URI
, _nlp_all :: URI
, _nlp_other :: (Map.Map T.Text URI) }
data NLPConfig = NLPConfig { _nlp_all :: URI
, _nlp_languages :: (Map.Map T.Text URI) }
deriving (Generic, Show)
makeLenses ''NLPConfig
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment