Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add softlines between applications and hang definitions #1578

Merged

Conversation

janmasrovira
Copy link
Collaborator

Closes #1577.

The important change is this:

 ppCode (Application l r) = do
     l' <- ppLeftExpression appFixity l
     r' <- ppRightExpression appFixity r
-    return $ l' <+> r'
+    return $ l' <> softline <> r'

The layout algorithm will insert a newline when the line goes above 80 characters.
After this change, the example code showed in #1577 displays thus:

  playMove : Maybe Nat → GameState → GameState;
  playMove nothing (state b p _) := state b p (continue
    "\nInvalid number, try again\n");
  playMove (just k) (state (board s) player e) := if (not (elem (==) k
    (possibleMoves (flatten s)))) (state (board s) player (continue
    "\nThe square is already occupied, try again\n")) (checkState (state (board
    (map (map (replace player k)) s)) (switch player) noError));

@janmasrovira janmasrovira added this to the 0.2.6 milestone Oct 5, 2022
@janmasrovira janmasrovira self-assigned this Oct 5, 2022
@janmasrovira janmasrovira linked an issue Oct 5, 2022 that may be closed by this pull request
@janmasrovira janmasrovira marked this pull request as ready for review October 5, 2022 17:00
@paulcadman paulcadman merged commit fc75660 into main Oct 6, 2022
@paulcadman paulcadman deleted the 1577-properly-newline-expressions-in-the-pretty-printer branch October 6, 2022 00:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Properly newline expressions in the pretty printer
2 participants