How to resolve 'Variable not in scope' error when running ghci?

53 Views Asked by At

After installing ghci stack, when I run just ghci (version 9.2.7) in terminal and enter some expression such as 1+1 I get the following error:

:1:2: error: Variable not in scope: (+) :: t0 -> t1 -> t

I have been unable to parse what the error message is suggesting or where to look for the issue. Thank you very much for your consideration.

1

There are 1 best solutions below

2
willeM_ Van Onsem On

You likely started ghci with -XNoImplicitPrelude, in that case it does not import the prelude.

You can import the prelude to load the basic functions:

ghci> import Prelude
ghci> 1+1
2

You should inspect the .cabal or .stack file of your project if it contains a directive to disable loading the Prelude implicitly.