From: Eugene Crosser Date: Tue, 6 May 2014 05:10:44 +0000 (+0400) Subject: use liftA2 to merge parsers X-Git-Tag: 0.9.0.1~5 X-Git-Url: http://average.org/gitweb/?a=commitdiff_plain;h=a674b931696b192a48fa99c494b2dd55266cfe58;p=pdns-pipe-nmc.git use liftA2 to merge parsers --- diff --git a/NmcDom.hs b/NmcDom.hs index 1205db5..8bfb6f3 100644 --- a/NmcDom.hs +++ b/NmcDom.hs @@ -9,7 +9,7 @@ module NmcDom ( NmcDom(..) ) where import Prelude hiding (length) -import Control.Applicative ((<$>), (<*>), empty, pure) +import Control.Applicative ((<$>), (<*>), liftA2, empty, pure) import Data.Char import Data.Text (Text, unpack) import Data.List (union) @@ -71,7 +71,8 @@ makeMx o = Just _ -> empty makeSubmap :: Object -> Parser (Maybe (Map String NmcDom)) -makeSubmap o = ((.).(.)) merge merge <$> takeTls o <*> takeSrv o <*> takeMap o +makeSubmap o = takeTls o `fmerge` takeSrv o `fmerge` takeMap o + where fmerge = liftA2 merge takeMap :: Object -> Parser (Maybe (Map String NmcDom)) takeMap o =