Skip to content

Silly vertical printing of long argument lists

Summary

GHC's pretty printer does not cope well with long argument lists.

Long argument lists do exist in practice, e.g, for records: https://github.com/agda/agda/blob/83a48d27010d2c292cc42100081a24f8df573688/src/full/Agda/TypeChecking/Serialise/Instances/Errors.hs#L192-L198

Steps to reproduce

type A = Int
data D = D A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A

test :: D -> D
test (D a b c d e f g h i j k l m n o p q r s t u v w x y z aa bb cc dd ee ff gg hh ii jj kk ll mm nn)
  = D a b c d e f g h i j k l m n o p q r s t u v w x y z aa bb cc dd ee ff gg hh ii jj kk ll mm nn

The compiler reports:


ManyConstructorArgs.hs:5:7: error:
    • The constructor ‘D’ should have 41 arguments, but has been given 40
    • In the pattern:
        D a
          b
          c
          d
          e
          f
          g
          h
          i
          j
          k
          l
          m
          n
          o
          p
          q
          r
          s
          t
          u
          v
          w
          x
          y
          z
          aa
          bb
          cc
          dd
          ee
          ff
          gg
          hh
          ii
          jj
          kk
          ll
          mm
          nn
      In an equation for ‘test’:
          test
            (D a
               b
               c
               d
               e
               f
               g
               h
               i
               j
               k
               l
               m
               n
               o
               p
               q
               r
               s
               t
               u
               v
               w
               x
               y
               z
               aa
               bb
               cc
               dd
               ee
               ff
               gg
               hh
               ii
               jj
               kk
               ll
               mm
               nn)
            = D a
                b
                c
                d
                e
                f
                g
                h
                i
                j
                k
                l
                m
                n
                o
                p
                q
                r
                s
                t
                u
                v
                w
                x
                y
                z
                aa
                bb
                cc
                dd
                ee
                ff
                gg
                hh
                ii
                jj
                kk
                ll
                mm
                nn
  |
5 | test (D a b c d e f g h i j k l m n o p q r s t u v w x y z aa bb cc dd ee ff gg hh ii jj kk ll mm nn)
  |       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Expected behavior

Print argument list in horizontal mode and wrap it somewhere.

Environment

  • GHC version used: 8.6.4
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information