2017-09-12 17:19:58 +03:00
|
|
|
#!/usr/bin/env runghc
|
2017-09-12 16:50:36 +03:00
|
|
|
-- This is a comment
|
2017-09-12 17:06:33 +03:00
|
|
|
|
2017-09-12 17:22:59 +03:00
|
|
|
-- Running interactivly:
|
|
|
|
-- gchi prax1.hs
|
|
|
|
-- and just call functions
|
|
|
|
-- :q ← quit
|
|
|
|
-- :r ← reload this script
|
|
|
|
-- :i prax.hs ← load another script or load this if not loaded before
|
2017-09-12 17:06:33 +03:00
|
|
|
doubleMe x = x * 3
|
|
|
|
|
|
|
|
doubleUs x y = doubleMe x + doubleMe y
|
|
|
|
|
|
|
|
doubleSmallNumber x = if x <= 100 then doubleMe x else x
|
|
|
|
|
|
|
|
-- ' <- uptick is used as convetion to mark lightly modified function
|
|
|
|
doubleSmallNumber' x = (if x <= 100 then doubleMe x else x) + 1
|
2017-09-12 17:19:58 +03:00
|
|
|
|
|
|
|
-- compile: ghc -dynamic prax1.hs
|
|
|
|
-- flag -dynamic is needed under Arch Linux, can be leaved off on ther envs
|
2017-09-12 17:22:59 +03:00
|
|
|
-- flag --make is needed?
|
2017-09-12 17:19:58 +03:00
|
|
|
|
2017-09-12 17:22:59 +03:00
|
|
|
-- runghc prax1.hs
|
|
|
|
-- this also works ↑ instead of save-compile-run cycle
|
2017-09-12 17:19:58 +03:00
|
|
|
|
2017-09-12 17:22:59 +03:00
|
|
|
-- entrypoint that is ran after compile
|
2017-09-12 17:19:58 +03:00
|
|
|
main = do
|
|
|
|
putStrLn "Hello World"
|
|
|
|
name <- getLine
|
|
|
|
putStrLn ("Hello " ++ name ++ "!")
|