Expression syntax in pattern [GHC-04584]

Pattern matching allows constructors and literals to be used to take apart values, exposing their contents. The syntax of patterns is very similar to that of the expressions that create values, but many constructs that are allowed in expression contexts are not meaningful patterns.

## Example Text

Expression syntax in pattern: [1 .. 10]

Examples

Using .. in pattern

When pattern matching, expressions are not allowed as patterns to be matched against. Instead, consider matching on a list, and using a conditional.

Error Message

before_dots.hs:3:3: error: [GHC-04584]
    Expression syntax in pattern: [1 .. 10]
  |
3 | f [1..10] = 0 
  |   ^^^^^^^
Matchingdots.hs
Before
module Matchingdots where

-- If the input is [1..10], return 0, otherwise return 1 
f :: [Int] -> Int
f [1..10] = 0 
f _ = 1 

After
module Matchingdots where

-- If the input is [1..10], return 0, otherwise return 1 
f :: [Int] -> Int
f xs 
    | xs == [1..10] = 0 
    | otherwise = 1