Skip to content

Commit bacab1c

Browse files
committed
Major upgrade
* Capture documentation * Parse documentation to retrieve important information * Diff annotations along with the text * Improve prettification * Upgrade to the lastest streamly and streamly-process
1 parent 9820142 commit bacab1c

File tree

7 files changed

+707
-225
lines changed

7 files changed

+707
-225
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
dist/
44
dist-newstyle*/
55

6+
.cabal.nix/
7+
68
# Local GHC and Cabal related files
79
.ghc.environment*
810
cabal.project.local

cli/Main.hs

Lines changed: 172 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,25 @@
1-
module Main (main) where
1+
module Main
2+
( main
3+
) where
24

35
--------------------------------------------------------------------------------
46
-- Imports
57
--------------------------------------------------------------------------------
68

79
import Control.Monad (when)
810
import Data.Function ((&))
11+
-- import Data.List (isInfixOf, foldl1)
912
import Streamly.Data.Stream (Stream)
1013
import System.Environment (getArgs)
1114

15+
-- import Debug.Trace (trace)
16+
17+
-- import qualified Data.Map as Map
1218
import qualified Streamly.Data.Fold as Fold
1319
import qualified Streamly.Data.Stream as Stream
1420
import qualified Streamly.Internal.FileSystem.File as File
15-
import qualified Streamly.Internal.Unicode.Stream as Unicode
1621
import qualified Streamly.Internal.System.Command as Command
22+
import qualified Streamly.Internal.Unicode.Stream as Unicode
1723

1824
import Diff
1925
import 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.
5562
checkoutAndGenerateHoogleFile :: String -> String -> IO (Maybe String)
5663
checkoutAndGenerateHoogleFile 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

6168
fileToLines :: String -> Stream IO String
6269
fileToLines path =
63-
File.toChunks path & Unicode.decodeUtf8Arrays
70+
File.readChunks path & Unicode.decodeUtf8Chunks
6471
& Stream.foldMany (Fold.takeEndBy_ (== '\n') Fold.toList)
6572

6673
main :: 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+
-}

default.nix

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -3,44 +3,44 @@
33
# To use ghc-8.10.7
44
# nix-shell --argstr compiler "ghc8107"
55

6-
{
7-
nixpkgs ?
8-
import (builtins.fetchTarball
9-
https://github.com/NixOS/nixpkgs/archive/refs/tags/22.05.tar.gz)
10-
{}
11-
, compiler ? "ghc922"
12-
}:
6+
{ nixpkgs ? import (builtins.fetchTarball
7+
"https://github.com/NixOS/nixpkgs/archive/refs/tags/22.05.tar.gz") { }
8+
, compiler ? "ghc922" }:
139
let
14-
utils =
15-
let src = fetchGit {
16-
url = "[email protected]:composewell/composewell-haskell.git";
17-
ref = "master";
18-
}; in (import "${src}/utils.nix") { inherit nixpkgs; };
10+
utils = let
11+
src = fetchGit {
12+
url = "[email protected]:composewell/composewell-haskell.git";
13+
ref = "master";
14+
};
15+
in (import "${src}/utils.nix") { inherit nixpkgs; };
1916

17+
haskellPackages = let
18+
src = fetchGit {
19+
url = "[email protected]:composewell/composewell-haskell.git";
20+
ref = "master";
21+
};
22+
in (import "${src}/haskellPackages.nix") {
23+
inherit nixpkgs;
24+
inherit compiler;
25+
};
2026

21-
haskellPackages =
22-
let src = fetchGit {
23-
url = "[email protected]:composewell/composewell-haskell.git";
24-
ref = "master";
25-
}; in (import "${src}/haskellPackages.nix")
26-
{ inherit nixpkgs;
27-
inherit compiler; };
27+
mkHaskellPackages = inShell:
28+
haskellPackages.override (old: {
29+
overrides = nixpkgs.lib.composeExtensions (old.overrides or (_: _: { }))
30+
(with nixpkgs.haskell.lib;
31+
self: super: {
32+
packdiff = utils.local super "packdiff" ./. "" inShell;
33+
streamly = utils.composewell super "streamly"
34+
"8240f5f870fe47623df99514aed6a542f80c9641";
35+
streamly-core = utils.composewellDir super "streamly"
36+
"8240f5f870fe47623df99514aed6a542f80c9641" "/core";
37+
streamly-process = utils.composewell super "streamly-process"
38+
"65e3ae489637099d0189a1ba184bb08a5c16de48";
39+
});
40+
});
2841

29-
mkHaskellPackages = inShell:
30-
haskellPackages.override (old: {
31-
overrides =
32-
nixpkgs.lib.composeExtensions
33-
(old.overrides or (_: _: {}))
34-
(with nixpkgs.haskell.lib; self: super: {
35-
packdiff =
36-
utils.local super "packdiff" ./. "" inShell;
37-
});
38-
});
42+
shellDrv = mkHaskellPackages true;
3943

40-
shellDrv = mkHaskellPackages true;
44+
shell = utils.mkShell shellDrv (p: [ p.packdiff ]) true;
4145

42-
shell = utils.mkShell shellDrv (p: [p.packdiff]) true;
43-
44-
in if nixpkgs.lib.inNixShell
45-
then shell
46-
else (mkHaskellPackages false).packdiff
46+
in if nixpkgs.lib.inNixShell then shell else (mkHaskellPackages false).packdiff

packdiff.cabal

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ library
3838
, Pretty
3939
-- other-extensions:
4040
build-depends: base >= 4.10 && < 4.17
41-
, streamly == 0.9.0.*
4241
, streamly-core == 0.1.0.*
4342
, containers >= 0.6 && < 0.7
4443
hs-source-dirs: src
@@ -49,7 +48,6 @@ executable packdiff
4948
main-is: Main.hs
5049
-- other-extensions:
5150
build-depends: base >= 4.10 && < 4.17
52-
, streamly == 0.9.0.*
5351
, streamly-core == 0.1.0.*
5452
, streamly-process == 0.2.0.*
5553
, packdiff

0 commit comments

Comments
 (0)