Skip to content

indentation in pretty-printed strings #24

@Wizek

Description

@Wizek

Current output:

( 1
, ( 2
  , Here is some show output
that has newlines
in it
  , 3
  )
)

Desired output:

( 1
, ( 2
  , Here is some custom show output
    that has newlines
    in it
  , 3
  )
)

Can be reproduced by e.g.

data Foo = Foo
instance Show Foo where show _ = "foo\nbar\nbaz"
main = pPrint (1, (2, Foo, 3))

Implementing this may be as simple as

unlines . ("  " <>) . lines

What do you say, @cdepillabout?

p.s. I love your library.

p.p.s I've just noticed that even strings with newlines seem to cause the same issue: pPrint (1, (2, "foo\nbar\nbaz", 3)). My proposed solution above would solve this case as well.

p.p.p.s In case you agree with my 'prognosis' and proposed 'treatment', would you prefer implementing the fix or would you like if I submitted a pull request?

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions