+ masterChildCommon =
+ Map.fromList . catMaybes . map procKV . Map.toList . Map.union
+ (Map.intersection master lastchild) $
+ (Map.intersection child master)
+ where procKV (k, v) =
+ case (Map.lookup k master, Map.lookup k child,
+ Map.lookup k lastchild) of
+ (Just m, Just c, Just lc) ->
+ if lc == c
+ then if lc == m
+ then Nothing
+ else Just (k, m)
+ else Just (k, c)
+ (Just m, Just c, Nothing) ->
+ if m == c
+ then Nothing
+ else Just (k, c)
+ (Just m, Nothing, Just lc) ->
+ if m == lc
+ then Nothing
+ else Just (k, m)
+ (Nothing, Just c, Just lc) ->
+ if c == lc
+ then Nothing
+ else Just (k, c)
+ _ -> Nothing
+