Using main in a Haskell file

I did a small part of haskell programming using GHCI, however our next task requires us to use only GHC to compile and test our code.

Due to how ghci works compared to ghc, you probably need to use the main function, and ghc looks for this function in your code.

My question is: if Haskell promotes type safety and no side effects, if only as part of the IO action, why should the bulk of any haskell program be an IO action?

Forgive me if I do not understand something fundamental, I just could not find any resources that ultimately explain this.

+4
source share
3

main IO, , , . Haskell , () , , , , . , - , , , - -, , . ,

main :: Int
main = 1 + 1

, , ? , main, , Haskell , , 1 + 1 - , . , -, , , IO.

+12

, . /.

Haskell - - .

+4

, - , , IO - , - , - ? , -, -, -, - . , .

+2
source

Source: https://habr.com/ru/post/1584281/


All Articles