Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ghci 'Not in scope:' message

Tags:

haskell

ghci

People also ask

What does variable not in scope mean?

2. "Not in scope" means you are trying to use a name which is not defined in the place in which you are trying to use it. In this case, it happens because you left out a comma after [1..x] , and so your definition of a within the list comprehension doesn't work as it should.

What does GHCi mean in Haskell?

GHCi [1] is GHC's interactive environment that includes an interactive debugger (see The GHCi Debugger). GHCi can. interactively evaluate Haskell expressions. interpret Haskell programs. load GHC-compiled modules.

How do I quit GHCi Haskell?

Quits GHCi. You can also quit by typing control-D at the prompt. Attempts to reload the current target set (see :load ) if any of the modules in the set, or any dependent module, has changed.

Does Haskell have variables?

So, YES Haskell has true variables. But it does not use mutable variables by default.


This is not a function code, it's function signature which can only be saved in a module along with function definition and the be loaded to GHCi.

This signature means that you're going to define a function lucky which gets an Integer and returns a String.

However if you're composing your functions using GHCi as interactive interpreter, you can let Haskell infer your function's type, e. g.:

ghci> let lucky x = show (x + 1)
ghci> :t lucky
lucky :: (Num a) => a -> String

If you want to try in the GHCI you could use multi-line command block

:{
lucky :: Int -> String
lucky a = show(a)
:}

:type lucky 
lucky :: Int -> String