I have programmed a really basic recursive function, but when I try to use it Haskell gives me an error.
This is the code:
import Data.Char
import Test.QuickCheck
potencia :: Integer -> Integer -> Integer
potencia x 0 = 1
potencia x n = x*(potencia x (n-1))
And this is the error:
<interactive>:27:1-8: error:
Variable not in scope: potencia :: Integer -> Integer -> t
If I delete the import of libreries it doesn´t give me the error anymore but I need them for later. I`m using the latest version of the Haskell platform.
I see you are defining your function in interactive shell. Most of Haskell's REPLs read and eval instructions line-by-line, so when you type potencia :: Integer -> Integer -> Integer
it is interpreted right at this moment, so compiler complains that potencia is lacking implementation. You should either:
:l
(recommended):set +m
and use let
statement to define variable with respect to indentation :{
and :}
;
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