module Language.Drasil.Code.Imperative.GOOL.LanguageRenderer.SwiftRenderer (
SwiftProject(..)
) where
import Prelude hiding (break,print,(<>),sin,cos,tan,floor)
import Text.PrettyPrint.HughesPJ (empty)
import Language.Drasil.Choices (ImplementationType(..))
import Language.Drasil.Code.Imperative.GOOL.ClassInterface ( AuxiliarySym(..),
auxFromData)
import Language.Drasil.Code.Imperative.README (ReadMeInfo(..))
import Drasil.GOOL (swiftName, swiftVersion)
import qualified
Language.Drasil.Code.Imperative.GOOL.LanguageRenderer.LanguagePolymorphic as
G (readMe, makefile, noRunIfLib, docIfEnabled)
import Language.Drasil.Code.Imperative.Build.AST (BuildConfig, Runnable,
DocConfig(..), asFragment, buildAll, nativeBinary, executable, sharedLibrary)
newtype SwiftProject a = SP {forall a. SwiftProject a -> a
unSP :: a}
instance Functor SwiftProject where
fmap :: forall a b. (a -> b) -> SwiftProject a -> SwiftProject b
fmap a -> b
f (SP a
x) = b -> SwiftProject b
forall a. a -> SwiftProject a
SP (a -> b
f a
x)
instance Applicative SwiftProject where
pure :: forall a. a -> SwiftProject a
pure = a -> SwiftProject a
forall a. a -> SwiftProject a
SP
(SP a -> b
f) <*> :: forall a b.
SwiftProject (a -> b) -> SwiftProject a -> SwiftProject b
<*> (SP a
x) = b -> SwiftProject b
forall a. a -> SwiftProject a
SP (a -> b
f a
x)
instance Monad SwiftProject where
SP a
x >>= :: forall a b.
SwiftProject a -> (a -> SwiftProject b) -> SwiftProject b
>>= a -> SwiftProject b
f = a -> SwiftProject b
f a
x
instance AuxiliarySym SwiftProject where
doxConfig :: String
-> SoftwareDossierState
-> Verbosity
-> SwiftProject FileAndContents
doxConfig String
_ SoftwareDossierState
_ Verbosity
_ = String -> Doc -> SwiftProject FileAndContents
forall (r :: * -> *).
Applicative r =>
String -> Doc -> r FileAndContents
auxFromData String
"" Doc
empty
readMe :: ReadMeInfo -> SwiftProject FileAndContents
readMe ReadMeInfo
rmi = ReadMeInfo -> SwiftProject FileAndContents
forall (r :: * -> *).
Applicative r =>
ReadMeInfo -> r FileAndContents
G.readMe ReadMeInfo
rmi {
langName = swiftName,
langVersion = swiftVersion}
optimizeDox :: SwiftProject Doc
optimizeDox = String -> SwiftProject Doc
forall a. HasCallStack => String -> a
error String
doxError
makefile :: [String]
-> ImplementationType
-> [Comments]
-> SoftwareDossierState
-> ProgData
-> SwiftProject FileAndContents
makefile [String]
fs ImplementationType
it [Comments]
cms = Maybe BuildConfig
-> Maybe Runnable
-> Maybe DocConfig
-> SoftwareDossierState
-> ProgData
-> SwiftProject FileAndContents
forall (r :: * -> *).
Applicative r =>
Maybe BuildConfig
-> Maybe Runnable
-> Maybe DocConfig
-> SoftwareDossierState
-> ProgData
-> r FileAndContents
G.makefile ([String] -> ImplementationType -> Maybe BuildConfig
swiftBuildConfig [String]
fs ImplementationType
it) (ImplementationType -> Maybe Runnable -> Maybe Runnable
G.noRunIfLib ImplementationType
it Maybe Runnable
swiftRunnable) ([Comments] -> DocConfig -> Maybe DocConfig
G.docIfEnabled [Comments]
cms (Dependencies -> [Command] -> DocConfig
DocConfig [] []))
auxHelperDoc :: SwiftProject Doc -> Doc
auxHelperDoc = SwiftProject Doc -> Doc
forall a. SwiftProject a -> a
unSP
swiftBuildConfig :: [FilePath] -> ImplementationType -> Maybe BuildConfig
swiftBuildConfig :: [String] -> ImplementationType -> Maybe BuildConfig
swiftBuildConfig [String]
fs ImplementationType
it = (Dependencies -> CommandFragment -> [Dependencies])
-> BuildName -> Maybe BuildConfig
buildAll (\Dependencies
i CommandFragment
o -> [String -> CommandFragment
asFragment String
"swiftc" CommandFragment -> Dependencies -> Dependencies
forall a. a -> [a] -> [a]
: Dependencies
i Dependencies -> Dependencies -> Dependencies
forall a. [a] -> [a] -> [a]
++
[String -> CommandFragment
asFragment String
"-o", CommandFragment
o] Dependencies -> Dependencies -> Dependencies
forall a. [a] -> [a] -> [a]
++ (String -> Dependencies) -> [String] -> Dependencies
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap (\String
f -> (String -> CommandFragment) -> [String] -> Dependencies
forall a b. (a -> b) -> [a] -> [b]
map String -> CommandFragment
asFragment [String
"-I", String
f]) [String]
fs Dependencies -> Dependencies -> Dependencies
forall a. [a] -> [a] -> [a]
++
ImplementationType -> Dependencies
asLib ImplementationType
it]) (ImplementationType -> BuildName
outName ImplementationType
it)
where asLib :: ImplementationType -> Dependencies
asLib ImplementationType
Library = [String -> CommandFragment
asFragment String
"-emit-library"]
asLib ImplementationType
Program = []
outName :: ImplementationType -> BuildName
outName ImplementationType
Library = BuildName
sharedLibrary
outName ImplementationType
Program = BuildName
executable
swiftRunnable :: Maybe Runnable
swiftRunnable :: Maybe Runnable
swiftRunnable = Maybe Runnable
nativeBinary
doxError :: String
doxError :: String
doxError = String
swiftName String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" is not compatible with Doxygen."