]> average.org Git - pdns-pipe-nmc.git/commitdiff
less ugly (but still ugly) merge
authorEugene Crosser <crosser@average.org>
Wed, 2 Apr 2014 07:52:28 +0000 (11:52 +0400)
committerEugene Crosser <crosser@average.org>
Wed, 2 Apr 2014 07:52:28 +0000 (11:52 +0400)
NmcJson.hs

index eb1bdb49fb7967544221b09dc55c390af3d7de3f..c92e363ce4b6a6f5d92e10f25806c8e58e45adf3 100644 (file)
@@ -135,26 +135,26 @@ descendNmc subdom rawdom =
 
 -- FIXME -- I hope there exists a better way to merge records!
 mergeNmc :: NmcDom -> NmcDom -> NmcDom
-mergeNmc sub dom = dom  { domService = choose dom domService sub
-                        , domIp = choose dom domIp sub
-                        , domIp6 = choose dom domIp6 sub
-                        , domTor = choose dom domTor sub
-                        , domI2p = choose dom domI2p sub
-                        , domFreenet = choose dom domFreenet sub
-                        , domAlias = choose dom domAlias sub
-                        , domTranslate = choose dom domTranslate sub
-                        , domEmail = choose dom domEmail sub
-                        , domLoc = choose dom domLoc sub
-                        , domInfo = choose dom domInfo sub
-                        , domNs = choose dom domNs sub
-                        , domDelegate = choose dom domDelegate sub
-                        , domImport = choose dom domImport sub
-                        , domFingerprint = choose dom domFingerprint sub
-                        , domTls = choose dom domTls sub
-                        , domDs = choose dom domDs sub
+mergeNmc sub dom = dom  { domService = choose domService
+                        , domIp =          choose domIp
+                        , domIp6 =         choose domIp6
+                        , domTor =         choose domTor
+                        , domI2p =         choose domI2p
+                        , domFreenet =     choose domFreenet
+                        , domAlias =       choose domAlias
+                        , domTranslate =   choose domTranslate
+                        , domEmail =       choose domEmail
+                        , domLoc =         choose domLoc
+                        , domInfo =        choose domInfo
+                        , domNs =          choose domNs
+                        , domDelegate =    choose domDelegate
+                        , domImport =      choose domImport
+                        , domFingerprint = choose domFingerprint
+                        , domTls =         choose domTls
+                        , domDs =          choose domDs
                         }
   where
-    choose :: NmcDom -> (NmcDom -> Maybe a) -> NmcDom -> Maybe a
-    choose sub t dom = case t dom of
-      Nothing -> t sub
+    choose :: (NmcDom -> Maybe a) -> Maybe a
+    choose field = case field dom of
+      Nothing -> field sub
       Just x  -> Just x