haskell-prettyprinter / haskell-prettyprinter/prettyprinter

Export a combination of flatAlt and group

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

Description

While looking at `dhall`'s [usage](https://github.com/dhall-lang/dhall-haskell/blob/6ccf08d6fb28ee35cf9e938cdce225e65ea84df6/dhall/src/Dhall/Pretty/Internal.hs) of `prettyprinter`, I noticed that `flatAlt` is always combined with `group`.

(The only direct use of `group` where the argument is not a `flatAlt`-expression is on the top-level [here](https://github.com/dhall-lang/dhall-haskell/blob/6ccf08d6fb28ee35cf9e938cdce225e65ea84df6/dhall/src/Dhall/Pretty/Internal.hs#L513).)

What I'm currently thinking about is something like

```
prefer :: Doc ann -> Doc ann -> Doc ann
prefer a b = group (flatAlt b a)
```

The order of arguments is reversed in comparison to `flatAlt` since in `prefer a b`, we "prefer" `a` over `b`.

Thoughts? Any ideas for a better name?!

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.