@@ -30,6 +30,100 @@ prettyTag Removed = "[R]"
3030prettyTag Same = " [S]"
3131prettyTag (Changed _) = " [C]"
3232
33+ isDeprecated :: [Annotation ] -> Bool
34+ isDeprecated anns =
35+ let f x =
36+ case x of
37+ Deprecated _ -> True
38+ _ -> False
39+ in not $ null $ filter f anns
40+
41+ -- Don't print if deprecated in Left
42+ -- Error out if deprecated in Left and not deprecated in Right
43+ -- Error out if deprecated in Right and Added
44+ prettyD0_ ::
45+ String
46+ -> Tagged (Attach (Diff [Annotation ]) (StatusTag EntityContextType )) EntityContextType
47+ -> [String ]
48+ prettyD0_ _ (Tagged (Attach (DLeft anns) Removed ) b) =
49+ if isDeprecated anns
50+ then [" " ]
51+ else [" [R] " ++ showECT b]
52+ prettyD0_ _ (Tagged (Attach (DRight anns) Added ) b) =
53+ if isDeprecated anns
54+ then [" " ]
55+ else [" [A] " ++ showECT b]
56+ prettyD0_ k (Tagged (Attach (DBoth annsL annsR) (Changed b1)) b) =
57+ if isDeprecated annsR && isDeprecated annsL
58+ then [" " ]
59+ else if isDeprecated annsR && not (isDeprecated annsL)
60+ then [" [D] " ++ showECT b1]
61+ else if not (isDeprecated annsR) && isDeprecated annsL
62+ then [" " ]
63+ else if b1 == b
64+ then [" " ]
65+ else concat
66+ [ [" [C] " ++ k]
67+ , indenter
68+ 4
69+ [" [O] " ++ showECT b, " [N] " ++ showECT b1]
70+ ]
71+ prettyD0_ _ (Tagged (Attach (DBoth annsL annsR) Same ) b) =
72+ if isDeprecated annsR && not (isDeprecated annsL)
73+ then [" [D] " ++ showECT b]
74+ else [" " ]
75+
76+ prettyD1_ ::
77+ String
78+ -> Tagged (Attach (Diff [Annotation ]) (StatusTag () )) (Map String (Tagged (Attach (Diff [Annotation ]) (StatusTag EntityContextType )) EntityContextType ))
79+ -> [String ]
80+ prettyD1_ k (Tagged (Attach (DLeft anns) Removed ) b) =
81+ if isDeprecated anns
82+ then [" " ]
83+ else [" [R] " ++ k]
84+ prettyD1_ k (Tagged (Attach (DRight anns) Added ) b) =
85+ if isDeprecated anns
86+ then [" " ]
87+ else concat [[" [A] " ++ k], indenter 4 (prettyD0 b)]
88+ prettyD1_ k (Tagged (Attach (DBoth annsL annsR) (Changed () )) b) =
89+ if isDeprecated annsR && isDeprecated annsL
90+ then [" " ]
91+ else if isDeprecated annsR && not (isDeprecated annsL)
92+ then concat [[" [D] " ++ k], indenter 4 (prettyD0 b)]
93+ else if not (isDeprecated annsR) && isDeprecated annsL
94+ then [" " ]
95+ else concat [[" [C] " ++ k], indenter 4 (prettyD0 b)]
96+ prettyD1_ k (Tagged (Attach (DBoth annsL annsR) Same ) b) =
97+ if isDeprecated annsR && not (isDeprecated annsL)
98+ then [" [D] " ++ k]
99+ else [" " ]
100+
101+ prettyAPI_ ::
102+ [Element ]
103+ -> ModuleName
104+ -> Tagged (Attach (Diff [Annotation ]) (StatusTag () )) (ModuleContextDefault (Attach (Diff [Annotation ]) (StatusTag () )) (Attach (Diff [Annotation ]) (StatusTag EntityContextType )))
105+ -> [String ]
106+ prettyAPI_ _ k (Tagged (Attach (DLeft anns) Removed ) b) =
107+ if isDeprecated anns
108+ then [" " ]
109+ else [" [R] " ++ k]
110+ prettyAPI_ elems k (Tagged (Attach (DRight anns) Added ) b) =
111+ if isDeprecated anns
112+ then [" " ]
113+ else concat [[" [A] " ++ k], indenter 4 (prettyMC elems b)]
114+ prettyAPI_ elems k (Tagged (Attach (DBoth annsL annsR) (Changed () )) b) =
115+ if isDeprecated annsR && isDeprecated annsL
116+ then [" " ]
117+ else if isDeprecated annsR && not (isDeprecated annsL)
118+ then concat [[" [D] " ++ k], indenter 4 (prettyMC elems b)]
119+ else if not (isDeprecated annsR) && isDeprecated annsL
120+ then [" " ]
121+ else concat [[" [C] " ++ k], indenter 4 (prettyMC elems b)]
122+ prettyAPI_ _ k (Tagged (Attach (DBoth annsL annsR) Same ) b) =
123+ if isDeprecated annsR && not (isDeprecated annsL)
124+ then [" [D] " ++ k]
125+ else [" " ]
126+
33127indenter :: Int -> [String ] -> [String ]
34128indenter i = map (replicate i ' ' ++ )
35129
@@ -48,55 +142,31 @@ data Element
48142 deriving (Eq )
49143
50144prettyD0 ::
51- Show d
52- => Map String (Tagged (Attach d (StatusTag EntityContextType )) EntityContextType )
145+ Map String (Tagged (Attach (Diff [Annotation ]) (StatusTag EntityContextType )) EntityContextType )
53146 -> [String ]
54147prettyD0 = SMap. foldlWithKey step initial
55148
56149 where
57150
58151 initial = []
59152
60- step a k (Tagged (Attach d Added ) b) =
61- unwords [" [A]" , show d, k, " :" , showECT b] : a
62- step a k (Tagged (Attach d Removed ) b) =
63- unwords [" [R]" , show d, k, " :" , showECT b] : a
64- -- step a k (Tagged Same b) = unwords ["[S]", k, ":", showECT b] : a
65- step a _ (Tagged (Attach _ Same ) _) = a
66- step a k (Tagged (Attach d (Changed b1)) b) =
67- concat
68- [ [unwords [" [C]" , show d, k, " :" ]]
69- , indenter
70- 4
71- [unwords [" [OLD]" , showECT b], unwords [" [NEW]" , showECT b1]]
72- , a
73- ]
153+ step a k t = prettyD0_ k t ++ a
74154
75155prettyD1 ::
76- Show d
77- => Bool
78- -> Map String (Tagged (Attach d (StatusTag () )) (Map String (Tagged (Attach d (StatusTag EntityContextType )) EntityContextType )))
156+ Bool
157+ -> Map String (Tagged (Attach (Diff [Annotation ]) (StatusTag () )) (Map String (Tagged (Attach (Diff [Annotation ]) (StatusTag EntityContextType )) EntityContextType )))
79158 -> [String ]
80159prettyD1 l = SMap. foldlWithKey step initial
81160
82161 where
83162
84163 initial = []
85164
86- step a _ (Tagged (Attach _d Same ) _) = a
87- step a k (Tagged (Attach d t) b) =
88- if l
89- then concat
90- [ [unwords [prettyTag t, show d, k]]
91- , indenter 4 (prettyD0 b)
92- , a
93- ]
94- else concat [[unwords [prettyTag t, show d, k]], a]
165+ step a k t = prettyD1_ k t ++ a
95166
96167prettyMC ::
97- Show d
98- => [Element ]
99- -> ModuleContextDefault (Attach d (StatusTag () )) (Attach d (StatusTag EntityContextType ))
168+ [Element ]
169+ -> ModuleContextDefault (Attach (Diff [Annotation ]) (StatusTag () )) (Attach (Diff [Annotation ]) (StatusTag EntityContextType ))
100170 -> [String ]
101171prettyMC elems ctx = concat $ map displayer $ nub elems
102172
@@ -113,21 +183,13 @@ prettyMC elems ctx = concat $ map displayer $ nub elems
113183
114184
115185prettyAPI ::
116- Show d
117- => [Element ]
118- -> API (Attach d (StatusTag () )) (Attach d (StatusTag () )) (Attach d (StatusTag EntityContextType ))
186+ [Element ]
187+ -> API (Attach (Diff [Annotation ]) (StatusTag () )) (Attach (Diff [Annotation ]) (StatusTag () )) (Attach (Diff [Annotation ]) (StatusTag EntityContextType ))
119188 -> String
120189prettyAPI elems = printer . SMap. foldlWithKey step initial
121190
122191 where
123192
124193 initial = []
125194
126- step a _ (Tagged (Attach _ Same ) _) = a
127- step a k (Tagged (Attach d t) b) =
128- let ptfy =
129- concat
130- [ [unwords [prettyTag t, show d, k]]
131- , indenter 4 (prettyMC elems b)
132- ]
133- in concat [ptfy, a]
195+ step a k t = prettyAPI_ elems k t ++ a
0 commit comments