mirror of
https://github.com/rowtype-yoga/royo.git
synced 2024-11-25 06:06:03 +03:00
Get rid of nested if-then-else (#4)
This commit is contained in:
parent
be5e28d2c8
commit
c283d6d5ac
@ -123,16 +123,12 @@ prepareOutput s =
|
||||
|
||||
prepareCode ∷ String -> String
|
||||
prepareCode code =
|
||||
if startsWith "module" code then
|
||||
code
|
||||
else
|
||||
if startsWith "import " code then
|
||||
moduleMain <> code
|
||||
else
|
||||
if (startsWith "main =" || contains (Pattern "\nmain =")) code then
|
||||
moduleMain <> importBasics <> code
|
||||
else
|
||||
moduleMain <> importBasics <> spyMain <> code
|
||||
let prepare
|
||||
| startsWith "module" code = code
|
||||
| startsWith "import " code = moduleMain <> code
|
||||
| (startsWith "main =" || contains (Pattern "\nmain =")) code = moduleMain <> importBasics <> code
|
||||
| otherwise = moduleMain <> importBasics <> spyMain <> code
|
||||
in prepare
|
||||
where
|
||||
moduleMain = "module Main where\n"
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user