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

parent e250af8a
...@@ -37,21 +37,15 @@ readConfig fp = do ...@@ -37,21 +37,15 @@ readConfig fp = do
ini <- readIniFile' fp ini <- readIniFile' fp
let val' = val ini iniSection 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_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 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 case mRet of
Nothing -> panic $ T.concat [ "Cannot read config file: _nlp_en = " Nothing -> panic $ T.concat [ "Cannot read config file: _nlp_all = "
, T.pack $ show m_nlp_en
, ", _nlp_fr = "
, T.pack $ show m_nlp_fr
, ", _nlp_all = "
, T.pack $ show m_nlp_all , T.pack $ show m_nlp_all
, ", _nlp_other = " , ", _nlp_other = "
, T.pack $ show m_nlp_other ] , T.pack $ show m_nlp_other ]
......
...@@ -21,10 +21,8 @@ import Network.Socket (PortNumber) ...@@ -21,10 +21,8 @@ import Network.Socket (PortNumber)
import Network.URI (URI) import Network.URI (URI)
import Protolude import Protolude
data NLPConfig = NLPConfig { _nlp_en :: URI data NLPConfig = NLPConfig { _nlp_all :: URI
, _nlp_fr :: URI , _nlp_languages :: (Map.Map T.Text URI) }
, _nlp_all :: URI
, _nlp_other :: (Map.Map T.Text URI) }
deriving (Generic, Show) deriving (Generic, Show)
makeLenses ''NLPConfig 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