Haskell's first steps compile an error

I just installed the Haskell platform with the installer from here https://www.haskell.org/platform/mac.html

Now, like me, I created a very simple program, just to see if it works:

f :: Int -> Int
f x = x + 2

but when i do

runhaskell test.hs

he returns

test.hs: 0: 53: error:

• Variable not in scope: main :: IO a0

• Perhaps you meant 'min (imported from Prelude)

if i run

ghc test.hs

he returns

The main functioning of the IO is not defined in the module "Main

indicating only the first char of the first line "f"

+4
source share
1 answer

Haskell, . . , Haskell .

main (ghc , ). main IO a. , (IO), .

f, , , f.

, main:

main :: IO ()
main = print (f 2)

, . , main. main : print f 2. 4. main .

. , , .

, , ghci file.hs :

$ ghci testprogram.hs 
GHCi, version 8.0.2: http://www.haskell.org/ghc/  :? for help
[1 of 1] Compiling Main             ( testprogram.hs, interpreted )
Ok, modules loaded: Main.
*Main> f 2
4

, f 2, 4.

+6

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


All Articles