From: Eugene Crosser Date: Sat, 3 May 2014 17:21:54 +0000 (+0400) Subject: wip split subdoms - cosmetic X-Git-Tag: 0.9.0.1~6 X-Git-Url: http://average.org/gitweb/?a=commitdiff_plain;h=4b66831c60d39decdc515fb7878ce3c0339684bd;p=pdns-pipe-nmc.git wip split subdoms - cosmetic --- diff --git a/NmcDom.hs b/NmcDom.hs index 3b8f060..1205db5 100644 --- a/NmcDom.hs +++ b/NmcDom.hs @@ -78,8 +78,8 @@ takeMap o = case H.lookup "map" o of Nothing -> pure Nothing Just (Object mo) -> do - unsplit <- (parseJSON (Object mo) :: Parser (Maybe (Map String NmcDom))) - let result = fmap splitup unsplit + raw <- (parseJSON (Object mo) :: Parser (Maybe (Map String NmcDom))) + let result = fmap splitup raw return result where splitup :: Map String NmcDom -> Map String NmcDom @@ -87,12 +87,12 @@ takeMap o = stow fqdn sdom acc = M.insertWith merge fqdn' sdom' acc where (fqdn', sdom') = nest (filter (/= "") (splitOnDots fqdn), sdom) - splitOnDots s = splitOn "." s - nest ([], v) = (fqdn, v) -- can split result be empty? + splitOnDots s = splitOn "." s + nest ([], v) = (fqdn, v) -- preserve "self" map entry nest ([k], v) = (k, v) nest (k:ks, v) = nest (ks, def { domSubmap = Just (M.singleton k v) }) - _ -> empty + _ -> empty takeSrv :: Object -> Parser (Maybe (Map String NmcDom)) takeSrv o =