-
Notifications
You must be signed in to change notification settings - Fork 704
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Template cabal-install.cabal using zinza
- Loading branch information
Showing
13 changed files
with
1,293 additions
and
471 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
{-# LANGUAGE DeriveGeneric #-} | ||
{-# LANGUAGE ScopedTypeVariables #-} | ||
module Main (main) where | ||
|
||
import Control.Exception (SomeException (..), catch, displayException) | ||
import GHC.Generics (Generic) | ||
import System.Environment (getArgs) | ||
import System.Exit (exitFailure) | ||
|
||
import qualified Zinza as Z | ||
|
||
withIO :: (Bool -> FilePath -> FilePath -> IO a) -> IO a | ||
withIO k = do | ||
args <- getArgs | ||
case args of | ||
[dev',src,tgt] | ||
| Just dev <- parseBool dev' | ||
-> k dev src tgt `catch` \(SomeException e) -> do | ||
putStrLn $ "Exception: " ++ displayException e | ||
exitFailure | ||
_ -> do | ||
putStrLn "Usage cabal v2-run ... source.temeplate.ext target.ext" | ||
exitFailure | ||
where | ||
parseBool "True" = Just True | ||
parseBool "False" = Just False | ||
parseBool _ = Nothing | ||
|
||
|
||
main :: IO () | ||
main = withIO $ \dev src tgt -> do | ||
render <- Z.parseAndCompileTemplateIO src | ||
contents <- render $ Z dev () | ||
writeFile tgt contents | ||
|
||
------------------------------------------------------------------------------- | ||
-- Data | ||
------------------------------------------------------------------------------- | ||
|
||
data Z = Z | ||
{ zDev :: Bool | ||
, zUnused :: () | ||
} | ||
deriving (Generic) | ||
|
||
instance Z.Zinza Z where | ||
toType = Z.genericToTypeSFP | ||
toValue = Z.genericToValueSFP | ||
fromValue = Z.genericFromValueSFP |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.