on master help sign in
Add API comparison script.

--HG-- extra : convert_revision : 89c97ab8d86c410dccbc1a9efa553ff7d0c64516

commit22783d3ecbb00c3b056fa374648478e29145d4bb authorBryan O'Sullivan <bos@serpentine.com> dateFri 9 Oct 2009, 04:09 (17 years ago) parenta2a4524
1 file changed+24
scripts/ApiCompare.hs+24
scripts/ApiCompare.hsnew file+24
@@ -0,0 +1,24 @@
1+-- This script compares the strict and lazy Text APIs to ensure that
2+-- they're reasonably in sync.
3+
4+{-# LANGUAGE OverloadedStrings #-}
5+
6+import qualified Data.Set as S
7+import qualified Data.Text as T
8+import System.Process
9+
10+main = do
11+ let tidy pkg = (S.fromList . filter (T.isInfixOf "::") . T.lines .
12+ T.replace "GHC.Int.Int64" "Int" .
13+ T.replace "\n " "" .
14+ T.replace (T.append (T.pack pkg) ".") "" . T.pack) `fmap`
15+ readProcess "ghci" [] (":browse " ++ pkg)
16+ let diff a b = mapM_ (putStrLn . (" "++) . T.unpack) . S.toList $
17+ S.difference a b
18+ text <- tidy "Data.Text"
19+ lazy <- tidy "Data.Text.Lazy"
20+ putStrLn "In Data.Text:"
21+ diff text lazy
22+ putStrLn ""
23+ putStrLn "In Data.Text.Lazy:"
24+ diff lazy text