How to fix “variable not in scope” error in GHCI?

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:

  • Define it in external file and load it using :l (recommended)
  • Type :set +m and use let statement to define variable with respect to indentation
  • Surround your definition with :{ and :}
  • Put whole definition and declaration in one line separating each part with ;

Leave a Comment

tech