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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
module Check.AST.Pattern.Print where

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

import Types

-- find pattern putStrLn (show a) and recommend print instead
checkPrint :: Expression a -> Int -> CSM ()
checkPrint e _ =
  case e of
    (Apply
      sI
      (Variable
        _
        _
        (QualIdent
          _
          _
          (Ident _ "putStrLn" _)))
      (Paren
        _
        (Apply
          _
          (Variable
            _
            _
            (QualIdent
              _
              _
              (Ident _ "show" _)))
          _))) -> (report (Message
                            (getSpan sI)
                            ( text "superfluous code"
                            <+> colorizeKey "putStrLn (show a) "
                            )
                            ( text "instead of"
                            <+> colorizeKey "putStrLn (show a)"
                            <+> text "write"
                            <+> colorizeKey "print a")))
    _      -> return ()