Define `vsepHard`

Open Beginner friendly
#237 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
65/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Quiet
Tech stack
haskell
Domain
tooling

Research direction

Start by locating the existing n-ary concatenation functions for non-breaking spaces, breaking spaces, lines, and softlines. Add the missing vsepHard function alongside them using the issue's specified behavior, then verify that it keeps every pair of documents on separate lines and matches the surrounding API style.

Written by the indexing model from the issue text.

Description

Feature request

Define

vsepHard :: [ Doc a ] -> Doc a
vsepHard = concatWith (\x y -> x <> hardline <> y)

This is a missing function. We have n-ary concatenation functions for various separators: non-breaking spaces, breaking spaces, lines, softlines... but not hardlines.

vsepHard is useful when you have things that you just never want to lay out on a single line. For example, in a programming language you might define let-bindings like so

let 
  x = 1
  y = 2
in t

I always want the x and y bindings to be on separate lines. A more sophisticated version might use flatAlt to use a different syntax when grouped, but I think the simple approach of "just always break" is often useful.

Dominant language
Haskell
Stars
309
Forks
43
Avg merge
21h 25m
Merged PRs (30d)
1

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from haskell-prettyprinter/prettyprinter

All issues in haskell-prettyprinter/prettyprinter

Similar issues

More Haskell issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.