haskell-prettyprinter / haskell-prettyprinter/prettyprinter

`space`s not collapsed

Open
#159 8 comments 1 reaction 0 assignees View on GitHub
Feature request
Dominant language
Haskell
Stars
309
Forks
43
Avg merge
21h 25m
Merged PRs (30d)
1

Description

The following snippet

```haskell
putStrLn . renderString . layoutPretty defaultLayoutOptions $
pretty "a" <+> mempty <+> pretty "b"
```

gives this output:

```
a b
```

(two spaces between `a` and `b`). Most of the time I want spaces to collapse i.e. to have

```haskell
x <> space <> space === x <> space
```

because I often write things like `x <+> (if b then y else mempty) <+> z` and I want to have one space between `x` and `z` when `b` is `False`. _I think_, `pretty` (the library) works this way.

With the current behaviour I have to structure my pretty-printers in a weird non-compositional way. Is it maybe possible to add a `layoutCollapseSpaces :: Bool` option to `LayoutOptions`?

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.