codesnippets:firsthaskellprogram
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| codesnippets:firsthaskellprogram [2021/04/01 20:27] – [the first line declares that function ''main'' has type ''IO ()''] f2b216 | codesnippets:firsthaskellprogram [2025/10/08 00:48] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 2: | Line 2: | ||
| * main function with output, as a complete code example | * main function with output, as a complete code example | ||
| - | * which compiles | + | * compiles, error and warning free, with compiler: GHC 8.10.4, using compiler option |
| - | * warning free with | + | |
| - | * compiler: GHC 8.10.4 using -Wall | + | |
| * <code Haskell> | * <code Haskell> | ||
| main :: IO () | main :: IO () | ||
| Line 25: | Line 23: | ||
| * whereas '' | * whereas '' | ||
| * and ' | * and ' | ||
| - | * default package is '' | + | * default package is '' |
| * in the second line '' | * in the second line '' | ||
| * '' | * '' | ||
| Line 37: | Line 35: | ||
| ===== Explanation, | ===== Explanation, | ||
| + | |||
| + | * Haskell code repeated, from above | ||
| + | * <code Haskell> | ||
| + | main :: IO () | ||
| + | main = print ' | ||
| + | </ | ||
| ==== first line declares that function '' | ==== first line declares that function '' | ||
| * '' | * '' | ||
| - | * see the following | + | * see the following |
| * <code Haskell> | * <code Haskell> | ||
| main :: IO () | main :: IO () | ||
| Line 61: | Line 65: | ||
| * result type: '' | * result type: '' | ||
| * '' | * '' | ||
| - | * result type: '' | + | * result type: '' |
| * '' | * '' | ||
| * result type: '' | * result type: '' | ||
| * '' | * '' | ||
| - | * result type: '' | + | * result type: '' |
| * NOTE: | * NOTE: | ||
| * Types start always with upper case letters. | * Types start always with upper case letters. | ||
| - | * Type sigantures | + | * Type signatures |
| * Type type parameters start always with lower case letters. | * Type type parameters start always with lower case letters. | ||
| * the example executes with the following output: | * the example executes with the following output: | ||
| Line 77: | Line 81: | ||
| ==== second line declares that function '' | ==== second line declares that function '' | ||
| - | * expression '' | + | * expression '' |
| * it binds '' | * it binds '' | ||
| * when function '' | * when function '' | ||
| - | * expression '' | + | * expression '' |
| * it binds '' | * it binds '' | ||
| * when function '' | * when function '' | ||
| - | ==== the default package is prelude | + | ==== default package is Prelude |
| - | * prelude is part of library '' | + | * '' |
| - | * package '' | + | * package '' |
| * enables basic elements like functions, types, type classes, and instances | * enables basic elements like functions, types, type classes, and instances | ||
| * the import of such elements can be controlled in different ways | * the import of such elements can be controlled in different ways | ||
| - | * see also [[codesnippets: | + | * see also [[codesnippets: |
| + | ===== ✎ ===== | ||
| + | ~~DISCUSSION~~ | ||
codesnippets/firsthaskellprogram.1617301630.txt.gz · Last modified: (external edit)
