]> git.rmz.io Git - my-scheme.git/commitdiff
Hello World with argument
authorSamir Benmendil <me@rmz.io>
Sat, 13 Jan 2018 21:56:06 +0000 (21:56 +0000)
committerSamir Benmendil <me@rmz.io>
Sat, 13 Jan 2018 21:56:06 +0000 (21:56 +0000)
This will simply print "Hello, " followed by the first argument from the
commandline.

Every Haskell program needs to have a main "action" in the Main module.
This is the entry point.

Files starting with `module <Foo>` will be part of the `Foo` module.

By convention modules are capitalized and definitions aren't.

`import System.Environment` provides `getArgs` to access cli arguments.

Haskell is strongly typed and types may be assigned with `::`. In this case
`main` is of type `IO ()` which is an IO action holding no information.
(more on that later hopefully, as I don't fully understand that.)

app/Main.hs

index de1c1ab35c4ad21e14ec824121b9710418b75c39..c0766c1faa3645d237fed54bc0e83d3dbcdd4d08 100644 (file)
@@ -1,6 +1,7 @@
 module Main where
-
-import Lib
+import System.Environment
 
 main :: IO ()
-main = someFunc
+main = do
+    args <- getArgs
+    putStrLn ("Hello, " ++ args !! 0)