cabal init -i: add the GHC2021 language option (fix #8265)
[cabal.git] / cabal-dev-scripts / src / GenValidateDockerfile.hs
blobc5a5c0c7cd7b66619eb0aa7f4bfa27546c3b3638
1 {-# LANGUAGE DeriveGeneric #-}
2 {-# LANGUAGE ScopedTypeVariables #-}
3 module Main (main) where
5 import Control.Exception (SomeException (..), catch, displayException)
6 import GHC.Generics (Generic)
7 import System.Environment (getArgs)
8 import System.Exit (exitFailure)
10 import qualified Data.Map as Map
11 import qualified Zinza as Z
13 withIO :: (String -> FilePath -> FilePath -> IO a) -> IO a
14 withIO k = do
15 args <- getArgs
16 case args of
17 [version,src,tgt]
18 -> k version src tgt `catch` \(SomeException e) -> do
19 putStrLn $ "Exception: " ++ displayException e
20 exitFailure
21 _ -> do
22 putStrLn "Usage cabal v2-run ... version"
23 exitFailure
25 main :: IO ()
26 main = withIO $ \version src tgt -> do
27 render <- Z.parseAndCompileTemplateIO src
28 case Map.lookup version params of
29 Just z -> do
30 contents <- render z
31 writeFile tgt contents
33 Nothing -> do
34 putStrLn $ "Unknown version " ++ version
35 exitFailure
37 -------------------------------------------------------------------------------
38 -- Params
39 -------------------------------------------------------------------------------
41 params :: Map.Map String Z
42 params = Map.fromList
43 [ pair "8.10.4" $ Z "ghc-8.10.4" "8.10.4-bionic" False True False True ""
44 , pair "8.8.4" $ Z "ghc-8.8.4" "8.8.4-bionic" False True False True "--doctest --solver-benchmarks --complete-hackage"
45 , pair "8.6.5" $ Z "ghc-8.6.5" "8.6.5-bionic" False True False True ""
46 , pair "8.4.4" $ Z "ghc-8.4.4" "8.4.4-bionic" False True False True ""
47 , pair "8.2.2" $ Z "ghc-8.2.2" "8.2.2-bionic" True True False True ""
48 , pair "8.0.2" $ Z "ghc-8.0.2" "8.0.2-bionic" True True False True ""
50 where
51 pair = (,)
53 -------------------------------------------------------------------------------
54 -- Data
55 -------------------------------------------------------------------------------
57 data Z = Z
58 { zGhc :: String
59 , zImage :: String
60 , zParsecCompat :: Bool
61 , zHasTransformers :: Bool
62 , zNeedsDynamic :: Bool
63 , zClient :: Bool
64 , zArgs :: String
66 deriving (Generic)
68 instance Z.Zinza Z where
69 toType = Z.genericToTypeSFP
70 toValue = Z.genericToValueSFP
71 fromValue = Z.genericFromValueSFP