1- module Main (main ) where
1+ module Main
2+ ( main
3+ ) where
24
35--------------------------------------------------------------------------------
46-- Imports
57--------------------------------------------------------------------------------
68
79import Control.Monad (when )
810import Data.Function ((&) )
11+ -- import Data.List (isInfixOf, foldl1)
912import Streamly.Data.Stream (Stream )
1013import System.Environment (getArgs )
1114
15+ -- import Debug.Trace (trace)
16+
17+ -- import qualified Data.Map as Map
1218import qualified Streamly.Data.Fold as Fold
1319import qualified Streamly.Data.Stream as Stream
1420import qualified Streamly.Internal.FileSystem.File as File
15- import qualified Streamly.Internal.Unicode.Stream as Unicode
1621import qualified Streamly.Internal.System.Command as Command
22+ import qualified Streamly.Internal.Unicode.Stream as Unicode
1723
1824import Diff
1925import HoogleFileParser
@@ -50,17 +56,18 @@ generateHoogleFile target bd =
5056 , " --haddock-hoogle"
5157 , " --builddir=" ++ bd
5258 ]
53- in Command. toLines Fold. toList cmd & Stream. fold Fold. last
59+ in Command. toLines Fold. toList cmd & Stream. fold Fold. latest
5460
61+ -- XXX Cache the file for ther version by default.
5562checkoutAndGenerateHoogleFile :: String -> String -> IO (Maybe String )
5663checkoutAndGenerateHoogleFile target rev = do
5764 step $ unwords [" Generating haddock file for" , rev]
5865 checkoutRevision rev
59- generateHoogleFile target rev
66+ generateHoogleFile target ( " dist-newstyle- " ++ rev)
6067
6168fileToLines :: String -> Stream IO String
6269fileToLines path =
63- File. toChunks path & Unicode. decodeUtf8Arrays
70+ File. readChunks path & Unicode. decodeUtf8Chunks
6471 & Stream. foldMany (Fold. takeEndBy_ (== ' \n ' ) Fold. toList)
6572
6673main :: IO ()
@@ -77,6 +84,164 @@ main = do
7784 api1 <-
7885 fileToLines file1
7986 & Stream. fold (haddockParseFold Removed Removed Removed )
80- api2 <- fileToLines file2 & Stream. fold (haddockParseFold Added Added Added )
87+ & fmap
88+ (mapAPITags
89+ (mapAttachment (DLeft . parseDoc))
90+ (mapAttachment (DLeft . parseDoc))
91+ (mapAttachment (DLeft . parseDoc)))
92+ api2 <-
93+ fileToLines file2 & Stream. fold (haddockParseFold Added Added Added )
94+ & fmap
95+ (mapAPITags
96+ (mapAttachment (DRight . parseDoc))
97+ (mapAttachment (DRight . parseDoc))
98+ (mapAttachment (DRight . parseDoc)))
8199 step " Printing diff"
82- putStrLn $ prettyAPI False Nothing (diffAPI api1 api2)
100+ let elems =
101+ [ ELClasses
102+ , ELDataTypes True
103+ , ELFixities
104+ , ELInstances True
105+ , ELNewTypes True
106+ , ELPatterns
107+ , ELTypeAliases
108+ , ELFunctions
109+ ]
110+ putStrLn $ prettyAPI elems (diffAPI api1 api2)
111+
112+ -- TODO:
113+
114+ -- Deprecated in previous release but not in this release
115+ -- Deprecated in this release and in previous release
116+ -- Deprecated in this release
117+
118+ -- APIs that don't have since annotations
119+ -- APIs that don't have complexity annotations
120+ -- APIs that have any Pre-release or Internal annotations
121+
122+ -- inspect module, individual elements
123+
124+ -- Breaking changes: API in the released modules that existed before but is
125+ -- changed now.
126+ -- - Get released modules from (streamly:0.8.3)
127+ -- - Get released modules from (streamly:master + streamly-core:master)
128+ -- - Filter out modules that have been deprecated in (streamly:0.8.3)
129+ -- - Filter out APIs that have been deprecated in (streamly:0.8.3)
130+
131+ {-
132+
133+
134+ main :: IO ()
135+ main = do
136+ (Just file083) <-
137+ checkoutAndGenerateHoogleFile "streamly" "v0.8.3"
138+ (Just fileMaster) <-
139+ checkoutAndGenerateHoogleFile "streamly" "release-tasks"
140+ (Just fileCore) <-
141+ checkoutAndGenerateHoogleFile "streamly-core" "release-tasks"
142+ step "Hoogle files"
143+ putStrLn file083
144+ putStrLn fileMaster
145+ putStrLn fileCore
146+ api083 <-
147+ fileToLines file083
148+ & Stream.fold (haddockParseFold Removed Removed Removed)
149+ & fmap
150+ (mapAPITags
151+ (mapAttachment (DLeft . parseDoc))
152+ (mapAttachment (DLeft . parseDoc))
153+ (mapAttachment (DLeft . parseDoc)))
154+ apiMaster <-
155+ fileToLines fileMaster
156+ & Stream.fold (haddockParseFold Added Added Added)
157+ & fmap
158+ (mapAPITags
159+ (mapAttachment (DRight . parseDoc))
160+ (mapAttachment (DRight . parseDoc))
161+ (mapAttachment (DRight . parseDoc)))
162+ apiCore <-
163+ fileToLines fileCore & Stream.fold (haddockParseFold Added Added Added)
164+ & fmap
165+ (mapAPITags
166+ (mapAttachment (DRight . parseDoc))
167+ (mapAttachment (DRight . parseDoc))
168+ (mapAttachment (DRight . parseDoc)))
169+ let api = mergeNonConflictingAPI apiMaster apiCore
170+ let isDeprecated anns =
171+ let f x =
172+ case x of
173+ Deprecated _ -> True
174+ _ -> False
175+ in not $ null $ filter f anns
176+
177+ isDeprecatedInBoth (Tagged (Attach (DBoth annl annr) _) _) =
178+ isDeprecated annl && isDeprecated annr
179+ isDeprecatedInBoth _ = False
180+
181+ isDeprecatedInLeft (Tagged (Attach (DLeft anns) _) _) =
182+ isDeprecated anns
183+ isDeprecatedInLeft (Tagged (Attach (DBoth anns _) _) _) =
184+ isDeprecated anns
185+ isDeprecatedInLeft _ = False
186+
187+ existsInBoth (Tagged (Attach (DBoth _ _) _) _) = True
188+ existsInBoth _ = False
189+
190+ isDeprecatedInRight (Tagged (Attach (DRight anns) _) _) =
191+ isDeprecated anns
192+ isDeprecatedInRight (Tagged (Attach (DBoth _ anns) _) _) =
193+ isDeprecated anns
194+ isDeprecatedInRight _ = False
195+
196+ isInternal x = "Internal" `isInfixOf` x
197+
198+ isNew (Tagged (Attach (DRight _) _) _) = True
199+ isNew _ = False
200+
201+ let api083Exposed = Map.filterWithKey (\k v -> not (isInternal k)) api083
202+ let apiExposed = Map.filterWithKey (\k v -> not (isInternal k)) api
203+
204+ let diff0 = diffAPI api083Exposed apiExposed
205+
206+ let diff1 =
207+ Map.filterWithKey
208+ (\k v -> not (isDeprecatedInBoth v) && existsInBoth v)
209+ diff0
210+
211+ let diff2 = Map.filterWithKey (\k v -> isDeprecatedInRight v) diff1
212+
213+ let diff3 =
214+ Map.filterWithKey
215+ (\k v -> k == "Streamly.Network.Socket")
216+ diff1
217+
218+ let elems =
219+ [ ELClasses
220+ , ELDataTypes True
221+ , ELFixities
222+ , ELInstances True
223+ , ELNewTypes True
224+ , ELPatterns
225+ , ELTypeAliases
226+ , ELFunctions
227+ ]
228+
229+ -- putStrLn $ prettyAPI elems diff1
230+
231+ putStrLn
232+ $ printer
233+ $ prettyMC
234+ elems
235+ (diffModuleContext
236+ (untag (api083Exposed Map.! "Streamly.Prelude"))
237+ (foldl1
238+ mergeModulesLeaningLeft $
239+ map untag
240+ [ apiExposed Map.! "Streamly.Data.Stream"
241+ , apiExposed Map.! "Streamly.Data.Stream.Concurrent"
242+ , apiExposed Map.! "Streamly.Data.Stream.Exception"
243+ , apiExposed Map.! "Streamly.Data.Stream.Time"
244+ , apiExposed Map.! "Streamly.Data.Fold"
245+ ]))
246+
247+ -}
0 commit comments