I am from zero to Haskell, and I have the following error that can't get away. Basically t2 is trying to use the function add1 defined in the other module t1. So
t1.hs-----
module t1 (add1) where
add1 :: Int -> Int
add1 x = x + 1
t2.hs-----
module t2 where
import t1
add1 2
The error always says parse error on inputt2'`
What's the problem?
Module names should be uppercase, your t2.hs file also has some issues, I've modified it so you should be able to run it with runghc t2.hs and see some output:
t1.hs
module T1 (add1) where
add1 :: Int -> Int
add1 x = x + 1
t2.hs
module T2 where
import T1
main = do
let x = add1 2
putStrLn (show x)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With