Command syntax in pattern [GHC-98980]

Language extension: Arrows

Arrows are an abstraction for computations that has special syntactic support in GHC. When the Arrows extension is enabled, some expressions that would normally be interpreted as containing the infix operators -< and -<< are instead interpreted as a new syntactic category of commands. These commands do not make sense as patterns, and using them in a pattern context is an error.

Examples

A command in a pattern

Message

CommandPattern.hs:4:4: error: [GHC-98980]
    Command syntax in pattern: y -< x
  |
4 | f (y -< x) = 5
  |    ^^^^^^

Explanation

In this example, the command y -< x is used where a pattern is expected. To fix the error, replace the command with a pattern.

CommandPattern.hs
Before
{-# LANGUAGE Arrows #-}
module CommandPattern where

f (y -< x) = 5
After
{-# LANGUAGE Arrows #-}
module CommandPattern where

f _ = 5