{-# LANGUAGE QuasiQuotes #-}
module Drasil.Generator.CaseStudyVariants
( caseStudyMainSRS,
caseStudyMainSRSWCode,
caseStudyMainSRSWCodeZoo,
)
where
import Control.Lens ((^.))
import Drasil.FileHandling (FileLayout, OverwritePolicy(..), directory, localPath, ps,
writeFiles)
import Drasil.SRS (SRSDecl, SmithEtAlSRS, genSmithEtAlSrs, typeCheckSI)
import Language.Drasil.Code (Choices)
import Drasil.Generator.Code (genCode, genCodeZoo)
import Drasil.Generator.WriteSystem (setSystemLocale)
import Drasil.System (HasProjectName(..))
writeSmithEtAlSrs :: SmithEtAlSRS -> SRSDecl -> String -> IO [FileLayout]
writeSmithEtAlSrs :: SmithEtAlSRS -> SRSDecl -> String -> IO [FileLayout]
writeSmithEtAlSrs SmithEtAlSRS
syst SRSDecl
srsDecl String
srsFileName = do
SmithEtAlSRS -> IO ()
typeCheckSI SmithEtAlSRS
syst
[FileLayout] -> IO [FileLayout]
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure ([FileLayout] -> IO [FileLayout])
-> [FileLayout] -> IO [FileLayout]
forall a b. (a -> b) -> a -> b
$ SmithEtAlSRS -> SRSDecl -> String -> [FileLayout]
genSmithEtAlSrs SmithEtAlSRS
syst SRSDecl
srsDecl String
srsFileName
caseStudyMainSRS :: SmithEtAlSRS -> SRSDecl -> String -> IO ()
caseStudyMainSRS :: SmithEtAlSRS -> SRSDecl -> String -> IO ()
caseStudyMainSRS SmithEtAlSRS
syst SRSDecl
srsDecl String
srsFileName = do
IO ()
setSystemLocale
let exampleName :: String
exampleName = SmithEtAlSRS
syst SmithEtAlSRS -> Getting String SmithEtAlSRS String -> String
forall s a. s -> Getting a s a -> a
^. Getting String SmithEtAlSRS String
forall c. HasProjectName c => Lens' c String
Lens' SmithEtAlSRS String
projRepoName
docLayouts <- SmithEtAlSRS -> SRSDecl -> String -> IO [FileLayout]
writeSmithEtAlSrs SmithEtAlSRS
syst SRSDecl
srsDecl String
srsFileName
writeFiles OverwriteAllowed localPath $ directory [ps|{exampleName}|] docLayouts
caseStudyMainSRSWCode :: SmithEtAlSRS -> SRSDecl -> String -> Choices -> IO ()
caseStudyMainSRSWCode :: SmithEtAlSRS -> SRSDecl -> String -> Choices -> IO ()
caseStudyMainSRSWCode SmithEtAlSRS
syst SRSDecl
srsDecl String
srsFileName Choices
choices = do
IO ()
setSystemLocale
let exampleName :: String
exampleName = SmithEtAlSRS
syst SmithEtAlSRS -> Getting String SmithEtAlSRS String -> String
forall s a. s -> Getting a s a -> a
^. Getting String SmithEtAlSRS String
forall c. HasProjectName c => Lens' c String
Lens' SmithEtAlSRS String
projRepoName
docLayouts <- SmithEtAlSRS -> SRSDecl -> String -> IO [FileLayout]
writeSmithEtAlSrs SmithEtAlSRS
syst SRSDecl
srsDecl String
srsFileName
srcLayout <- genCode syst choices
writeFiles OverwriteAllowed localPath $ directory [ps|{exampleName}|] $ srcLayout : docLayouts
caseStudyMainSRSWCodeZoo :: SmithEtAlSRS -> SRSDecl -> String -> [Choices] -> IO ()
caseStudyMainSRSWCodeZoo :: SmithEtAlSRS -> SRSDecl -> String -> [Choices] -> IO ()
caseStudyMainSRSWCodeZoo SmithEtAlSRS
syst SRSDecl
srsDecl String
srsFileName [Choices]
choices = do
IO ()
setSystemLocale
let exampleName :: String
exampleName = SmithEtAlSRS
syst SmithEtAlSRS -> Getting String SmithEtAlSRS String -> String
forall s a. s -> Getting a s a -> a
^. Getting String SmithEtAlSRS String
forall c. HasProjectName c => Lens' c String
Lens' SmithEtAlSRS String
projRepoName
docLayouts <- SmithEtAlSRS -> SRSDecl -> String -> IO [FileLayout]
writeSmithEtAlSrs SmithEtAlSRS
syst SRSDecl
srsDecl String
srsFileName
zooLayouts <- genCodeZoo syst choices
let layout = PathSegment -> [FileLayout] -> FileLayout
forall (f :: * -> *).
Foldable f =>
PathSegment -> f FileLayout -> FileLayout
directory [ps|{exampleName}|] ([FileLayout] -> FileLayout) -> [FileLayout] -> FileLayout
forall a b. (a -> b) -> a -> b
$ [FileLayout]
docLayouts [FileLayout] -> [FileLayout] -> [FileLayout]
forall a. [a] -> [a] -> [a]
++ [FileLayout]
zooLayouts
writeFiles OverwriteAllowed localPath layout