Get rid of nested if-then-else (#4)

This commit is contained in:
Renegatto 2022-01-23 18:42:51 +03:00 committed by GitHub
parent be5e28d2c8
commit c283d6d5ac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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"