{-# LANGUAGE DeriveGeneric #-}

module Distribution.Simple.Build.PackageInfoModule.Z (render, Z (..)) where

import Distribution.ZinzaPrelude

data Z = Z
  { Z -> String
zPackageName :: String,
    Z -> String
zVersionDigits :: String,
    Z -> String
zSynopsis :: String,
    Z -> String
zCopyright :: String,
    Z -> String
zHomepage :: String,
    Z -> Bool
zSupportsNoRebindableSyntax :: Bool
  }
  deriving ((forall x. Z -> Rep Z x) -> (forall x. Rep Z x -> Z) -> Generic Z
forall x. Rep Z x -> Z
forall x. Z -> Rep Z x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. Z -> Rep Z x
from :: forall x. Z -> Rep Z x
$cto :: forall x. Rep Z x -> Z
to :: forall x. Rep Z x -> Z
Generic)

render :: Z -> String
render :: Z -> String
render Z
z_root = Writer () -> String
forall a. Writer a -> String
execWriter (Writer () -> String) -> Writer () -> String
forall a b. (a -> b) -> a -> b
$ do
  if (Z -> Bool
zSupportsNoRebindableSyntax Z
z_root)
  then do
    String -> Writer ()
tell String
"{-# LANGUAGE NoRebindableSyntax #-}\n"
    () -> Writer ()
forall a. a -> Writer a
forall (m :: * -> *) a. Monad m => a -> m a
return ()
  else do
    () -> Writer ()
forall a. a -> Writer a
forall (m :: * -> *) a. Monad m => a -> m a
return ()
  String -> Writer ()
tell String
"{-# OPTIONS_GHC -fno-warn-missing-import-lists #-}\n"
  String -> Writer ()
tell String
"{-# OPTIONS_GHC -w #-}\n"
  String -> Writer ()
tell String
"module PackageInfo_"
  String -> Writer ()
tell (Z -> String
zPackageName Z
z_root)
  String -> Writer ()
tell String
" (\n"
  String -> Writer ()
tell String
"    name,\n"
  String -> Writer ()
tell String
"    version,\n"
  String -> Writer ()
tell String
"    synopsis,\n"
  String -> Writer ()
tell String
"    copyright,\n"
  String -> Writer ()
tell String
"    homepage,\n"
  String -> Writer ()
tell String
"  ) where\n"
  String -> Writer ()
tell String
"\n"
  String -> Writer ()
tell String
"import Data.Version (Version(..))\n"
  String -> Writer ()
tell String
"import Prelude\n"
  String -> Writer ()
tell String
"\n"
  String -> Writer ()
tell String
"name :: String\n"
  String -> Writer ()
tell String
"name = "
  String -> Writer ()
tell (String -> String
forall a. Show a => a -> String
show (String -> String) -> String -> String
forall a b. (a -> b) -> a -> b
$ Z -> String
zPackageName Z
z_root)
  String -> Writer ()
tell String
"\n"
  String -> Writer ()
tell String
"version :: Version\n"
  String -> Writer ()
tell String
"version = Version "
  String -> Writer ()
tell (Z -> String
zVersionDigits Z
z_root)
  String -> Writer ()
tell String
" []\n"
  String -> Writer ()
tell String
"\n"
  String -> Writer ()
tell String
"synopsis :: String\n"
  String -> Writer ()
tell String
"synopsis = "
  String -> Writer ()
tell (String -> String
forall a. Show a => a -> String
show (String -> String) -> String -> String
forall a b. (a -> b) -> a -> b
$ Z -> String
zSynopsis Z
z_root)
  String -> Writer ()
tell String
"\n"
  String -> Writer ()
tell String
"copyright :: String\n"
  String -> Writer ()
tell String
"copyright = "
  String -> Writer ()
tell (String -> String
forall a. Show a => a -> String
show (String -> String) -> String -> String
forall a b. (a -> b) -> a -> b
$ Z -> String
zCopyright Z
z_root)
  String -> Writer ()
tell String
"\n"
  String -> Writer ()
tell String
"homepage :: String\n"
  String -> Writer ()
tell String
"homepage = "
  String -> Writer ()
tell (String -> String
forall a. Show a => a -> String
show (String -> String) -> String -> String
forall a b. (a -> b) -> a -> b
$ Z -> String
zHomepage Z
z_root)
  String -> Writer ()
tell String
"\n"