module Build.Drasil.Make.MakeString where
type VarName = String
type VarVal = String
data MakeString = Mr String
| Mv MVar
| Mc MakeString MakeString
instance Semigroup MakeString where
<> :: MakeString -> MakeString -> MakeString
(<>) = MakeString -> MakeString -> MakeString
Mc
instance Monoid MakeString where
mempty :: MakeString
mempty = String -> MakeString
Mr String
""
data MVar = Os VarName VarVal VarVal VarVal
| Implicit VarName
| Free VarName
deriving MVar -> MVar -> Bool
(MVar -> MVar -> Bool) -> (MVar -> MVar -> Bool) -> Eq MVar
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: MVar -> MVar -> Bool
== :: MVar -> MVar -> Bool
$c/= :: MVar -> MVar -> Bool
/= :: MVar -> MVar -> Bool
Eq
(+:+) :: MakeString -> MakeString -> MakeString
MakeString
a +:+ :: MakeString -> MakeString -> MakeString
+:+ (Mr String
"") = MakeString
a
(Mr String
"") +:+ MakeString
b = MakeString
b
MakeString
a +:+ MakeString
b = MakeString
a MakeString -> MakeString -> MakeString
forall a. Semigroup a => a -> a -> a
<> String -> MakeString
Mr String
" " MakeString -> MakeString -> MakeString
forall a. Semigroup a => a -> a -> a
<> MakeString
b
renderMS :: MakeString -> String
renderMS :: MakeString -> String
renderMS (Mr String
s) = String
s
renderMS (Mv MVar
v) = (String -> String) -> MVar -> String
renderVar (\String
x -> String
"$(" String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
x String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
")") MVar
v
renderMS (Mc MakeString
a MakeString
b) = MakeString -> String
renderMS MakeString
a String -> String -> String
forall a. [a] -> [a] -> [a]
++ MakeString -> String
renderMS MakeString
b
renderVar :: (String -> String) -> MVar -> String
renderVar :: (String -> String) -> MVar -> String
renderVar String -> String
f (Os String
nm String
_ String
_ String
_) = String -> String
f String
nm
renderVar String -> String
f (Implicit String
nm) = String
"\"" String -> String -> String
forall a. [a] -> [a] -> [a]
++ String -> String
f String
nm String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"\""
renderVar String -> String
f (Free String
nm) = String -> String
f String
nm
makeS :: String -> MakeString
makeS :: String -> MakeString
makeS = String -> MakeString
Mr
mkWindowsVar :: VarName -> VarVal -> VarVal -> MakeString
mkWindowsVar :: String -> String -> String -> MakeString
mkWindowsVar String
n String
w String
e = MVar -> MakeString
Mv (MVar -> MakeString) -> MVar -> MakeString
forall a b. (a -> b) -> a -> b
$ String -> String -> String -> String -> MVar
Os String
n String
w String
e String
e
mkOSVar :: VarName -> VarVal -> VarVal -> VarVal -> MakeString
mkOSVar :: String -> String -> String -> String -> MakeString
mkOSVar String
n String
w String
m String
l = MVar -> MakeString
Mv (MVar -> MakeString) -> MVar -> MakeString
forall a b. (a -> b) -> a -> b
$ String -> String -> String -> String -> MVar
Os String
n String
w String
m String
l
mkImplicitVar :: VarName -> MakeString
mkImplicitVar :: String -> MakeString
mkImplicitVar = MVar -> MakeString
Mv (MVar -> MakeString) -> (String -> MVar) -> String -> MakeString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> MVar
Implicit
mkFreeVar :: VarName -> MakeString
mkFreeVar :: String -> MakeString
mkFreeVar = MVar -> MakeString
Mv (MVar -> MakeString) -> (String -> MVar) -> String -> MakeString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> MVar
Free