Variable not in scope [GHC-88464]

This error means that a variable name used in a program can’t be matched up with a corresponding binding site.

In Haskell, every variable comes into existence at a specific location. Examples include function argument names, local definitions with let, and module-level definitions. Creating a new name like this is called binding it, and the area of the program that can refer to the new name is called its scope. The message means that the provided name is not available for reference right where it is referred to.

Example error text

error: [GHC-88464] Variable not in scope: x

Examples

Attempted to refer to another function's argument

Error Message

Main.hs:5:7: error: [GHC-88464]
    Variable not in scope: x
  |
5 | g y = x
  |       ^

Description

In this example, the body of g attempts to refer to x, which is an argument to f and thus not available. The updated version renames g’s argument so that the x in the body can refer to it.

Main.hs
Before
module Main where

f x = 5

g y = x
After
module Main where

f x = 5

g x = x