1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
module Check.AST.Pattern.IdentFunc where

import Curry.SpanInfo
import Curry.Span
import Curry.Position
import Curry.Types
import Curry.Ident
import Text.Pretty

import Types

-- instead of lambda function \x -> x use id
checkIdentFunc :: Expression a -> Int -> CSM ()
checkIdentFunc e _ =
  case e of
    (Lambda
      sI
      [(VariablePattern _ _ ident1)]
      (Variable _ _ (QualIdent _ _ ident2))) -> whenM (ident1 == ident2)
                                                  (report ( Message
                                                            (getSpan sI)
                                                            ( text "superfluous code"
                                                            <+> colorizeKey "\\x -> x"
                                                            )
                                                            ( text "instead of"
                                                            <+> colorizeKey "\\x -> x"
                                                            <+> text "write"
                                                            <+> colorizeKey "id"
                                                            )
                                                          )
                                                  )
    _                                       -> return ()