One way to calculate 2^8 in haskell is by writing
product(replicate 8 2)
When trying to create a function for this, defined as follows...
power1 :: Integer → Integer → Integer
power1 n k | k < 0 = error errorText
power1 n 0 = 1
power1 n k = product(replicate k n)
i get the following error:
Couldn't match expected type 'Int' against inferred type 'Integer'
My guess is that I must use the fromInteger function somewhere... I'm just not sure where or how? Is it an interface or what is fromInteger, and how should I use it?
Thanks