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.
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.
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.
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
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