1 {-# LANGUAGE DeriveGeneric #-}
3 {-# LANGUAGE ScopedTypeVariables #-}
4 {-# LANGUAGE TemplateHaskell #-}
5 {-# OPTIONS_GHC -Wno-orphans #-}
6 module Main
(main
) where
8 import Control
.Exception
(SomeException
(..), catch, displayException
)
9 import Distribution
.Types
.PackageName
(PackageName
)
10 import Distribution
.Types
.Version
(Version
)
11 import GHC
.Generics
(Generic
)
12 import System
.Environment
(getArgs)
13 import System
.Exit
(exitFailure)
15 (ModuleConfig
(..), Ty
(..), Zinza
(..), genericFromValueSFP
, genericToTypeSFP
,
16 genericToValueSFP
, parseAndCompileModuleIO
)
20 -------------------------------------------------------------------------------
22 -------------------------------------------------------------------------------
26 { zPackageName
:: PackageName
27 , zVersionDigits
:: String
28 , zSupportsCpp
:: Bool
29 , zSupportsNoRebindableSyntax
:: Bool
31 , zRelocatable
:: Bool
39 , zDynlibdir
:: FilePath
40 , zDatadir
:: FilePath
41 , zLibexecdir
:: FilePath
42 , zSysconfdir
:: FilePath
44 , zNot
:: Bool -> Bool
45 , zManglePkgName
:: PackageName
-> String
50 -------------------------------------------------------------------------------
52 -------------------------------------------------------------------------------
54 withIO
:: (FilePath -> FilePath -> IO a
) -> IO a
58 [src
,tgt
] -> k src tgt `
catch`
\(SomeException e
) -> do
59 putStrLn $ "Exception: " ++ displayException e
62 putStrLn "Usage cabal v2-run ... source.temeplate.ext target.ext"
66 main
= withIO
$ \src tgt
-> do
67 mdl
<- parseAndCompileModuleIO config src
70 config
:: ModuleConfig Z
74 [ "{-# LANGUAGE DeriveGeneric #-}"
75 , "module Distribution.Simple.Build.PathsModule.Z (render, Z(..)) where"
76 , "import Distribution.ZinzaPrelude"
78 , "render :: Z -> String"
82 -------------------------------------------------------------------------------
84 -------------------------------------------------------------------------------
86 instance Zinza Z
where
87 toType
= genericToTypeSFP
88 toValue
= genericToValueSFP
89 fromValue
= genericFromValueSFP
91 -------------------------------------------------------------------------------
93 -------------------------------------------------------------------------------
95 instance Zinza PackageName
where
96 toType _
= TyString
(Just
"prettyShow")
97 toValue _
= error "not needed"
98 fromValue _
= error "not needed"
100 instance Zinza Version
where
101 toType _
= TyString
(Just
"prettyShow")
102 toValue _
= error "not needed"
103 fromValue _
= error "not needed"