T4437.hs 2.3 KB
Newer Older
1 2 3

module Main (main) where

4
import Control.Monad
5 6 7 8 9
import Data.List
import DynFlags
import Language.Haskell.Extension

main :: IO ()
10
main = do
dterei's avatar
dterei committed
11
    let ghcExtensions = [ ext | (ext, _, _) <- xFlags ]
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
        cabalExtensions = map show [ toEnum 0 :: KnownExtension .. ]
        ghcOnlyExtensions = ghcExtensions \\ cabalExtensions
        cabalOnlyExtensions = cabalExtensions \\ ghcExtensions
    check "GHC-only flags" expectedGhcOnlyExtensions ghcOnlyExtensions
    check "Cabal-only flags" expectedCabalOnlyExtensions cabalOnlyExtensions

check :: String -> [String] -> [String] -> IO ()
check title expected got
    = do let unexpected = got \\ expected
             missing = expected \\ got
             showProblems problemType problems
                 = unless (null problems) $
                       do putStrLn (title ++ ": " ++ problemType)
                          putStrLn "-----"
                          mapM_ putStrLn problems
                          putStrLn "-----"
                          putStrLn ""
         showProblems "Unexpected flags" unexpected
         showProblems "Missing flags" missing

expectedGhcOnlyExtensions :: [String]
33
expectedGhcOnlyExtensions = [
34
                             "AllowAmbiguousTypes",
35 36 37
                             "RelaxedLayout",
                             "AlternativeLayoutRule",
                             "AlternativeLayoutRuleTransitional",
38
                             "ExplicitNamespaces",
39
                             "TypeHoles",
40
                             "OverloadedLists",
41
                             "EmptyCase",
42
                             "AutoDeriveTypeable",
43
                             "NegativeLiterals",
44
                             "NumDecimals",
45
                             "NullaryTypeClasses"]
46 47 48 49 50 51 52 53 54 55 56

expectedCabalOnlyExtensions :: [String]
expectedCabalOnlyExtensions = ["Generics",
                               "ExtensibleRecords",
                               "RestrictedTypeSynonyms",
                               "HereDocuments",
                               "NewQualifiedOperators",
                               "XmlSyntax",
                               "RegularPatterns",
                               "SafeImports",
                               "Safe",
57
                               "Unsafe",
58
                               "Trustworthy"]
59