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 run ... source.temeplate.ext target.ext"
66 main
= withIO
$ \src tgt
-> do
67 mdl
<- parseAndCompileModuleIO config src
70 config
:: ModuleConfig Z
74 [ "{- FOURMOLU_DISABLE -}"
75 , "{-# LANGUAGE DeriveGeneric #-}"
76 , "module Distribution.Simple.Build.PathsModule.Z (render, Z(..)) where"
77 , "import Distribution.ZinzaPrelude"
79 , "render :: Z -> String"
83 -------------------------------------------------------------------------------
85 -------------------------------------------------------------------------------
87 instance Zinza Z
where
88 toType
= genericToTypeSFP
89 toValue
= genericToValueSFP
90 fromValue
= genericFromValueSFP
92 -------------------------------------------------------------------------------
94 -------------------------------------------------------------------------------
96 instance Zinza PackageName
where
97 toType _
= TyString
(Just
"prettyShow")
98 toValue _
= error "not needed"
99 fromValue _
= error "not needed"
101 instance Zinza Version
where
102 toType _
= TyString
(Just
"prettyShow")
103 toValue _
= error "not needed"
104 fromValue _
= error "not needed"