Skip to content

Commit 7d74227

Browse files
authored
Merge pull request #5578 from unisonweb/cp/decl-printing
Decl printing cleanup
2 parents bb88817 + 1146eea commit 7d74227

File tree

11 files changed

+23
-22
lines changed

11 files changed

+23
-22
lines changed

parser-typechecker/src/Unison/PrettyPrintEnv/Util.hs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{-# LANGUAGE OverloadedStrings #-}
22

3-
module Unison.PrettyPrintEnv.Util (declarationPPE, declarationPPEDecl) where
3+
module Unison.PrettyPrintEnv.Util (declarationPPE) where
44

55
import Unison.PrettyPrintEnv (PrettyPrintEnv (..))
66
import Unison.PrettyPrintEnv qualified as PPE
@@ -29,8 +29,3 @@ declarationPPE ppe ref = PrettyPrintEnv tm ty
2929
ty r
3030
| hash r == rootH = PPE.typeNames (unsuffixifiedPPE ppe) r
3131
| otherwise = PPE.typeNames (suffixifiedPPE ppe) r
32-
33-
-- The suffixed names uses the fully-qualified name for `r`
34-
declarationPPEDecl :: PrettyPrintEnvDecl -> Reference -> PrettyPrintEnvDecl
35-
declarationPPEDecl ppe r =
36-
ppe {suffixifiedPPE = declarationPPE ppe r}

parser-typechecker/src/Unison/Syntax/DeclPrinter.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,9 @@ prettyGADT ::
8484
DataDeclaration v a ->
8585
Pretty SyntaxText
8686
prettyGADT env ctorType r name dd =
87-
P.hang header . P.lines $
88-
constructor <$> zip [0 ..] (DD.constructors' dd)
87+
header <> P.newline <> P.indentN 2 constructors
8988
where
89+
constructors = P.lines (constructor <$> zip [0 ..] (DD.constructors' dd))
9090
constructor (n, (_, _, t)) =
9191
prettyPattern (PPED.unsuffixifiedPPE env) ctorType name (ConstructorReference r n)
9292
<> fmt S.TypeAscriptionColon " :"

unison-cli/src/Unison/Cli/Pretty.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,7 @@ prettyType pped (n, r, dt) =
466466
case dt of
467467
MissingObject r -> missingDefinitionMsg n r
468468
BuiltinObject _ -> builtin n
469-
UserObject decl -> DeclPrinter.prettyDecl (PPED.biasTo (maybeToList $ HQ.toName n) $ PPE.declarationPPEDecl pped r) r n decl
469+
UserObject decl -> DeclPrinter.prettyDecl (PPED.biasTo (maybeToList $ HQ.toName n) $ pped) r n decl
470470
where
471471
builtin n = P.wrap $ "--" <> prettyHashQualified n <> " is built-in."
472472

unison-cli/src/Unison/CommandLine/OutputMessages.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2634,7 +2634,7 @@ displayDefinitions' ppe0 types terms = P.syntaxToColor $ P.sep "\n\n" (prettyTyp
26342634
case dt of
26352635
MissingObject r -> missing n r
26362636
BuiltinObject _ -> builtin n
2637-
UserObject decl -> DeclPrinter.prettyDecl (PPE.declarationPPEDecl ppe0 r) r n decl
2637+
UserObject decl -> DeclPrinter.prettyDecl ppe0 r n decl
26382638
builtin n = P.wrap $ "--" <> prettyHashQualified n <> " is built-in."
26392639
missing n r =
26402640
P.wrap

unison-share-api/src/Unison/Server/Backend.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1193,7 +1193,7 @@ typesToSyntax suff width ppe0 types =
11931193
MissingObject sh -> MissingObject sh
11941194
UserObject d ->
11951195
UserObject . Pretty.render width $
1196-
DeclPrinter.prettyDecl (PPE.declarationPPEDecl ppe0 r) r n d
1196+
DeclPrinter.prettyDecl ppe0 r n d
11971197
where
11981198
ppeDecl =
11991199
if suffixified suff

unison-src/transcripts-manual/rewrites.output.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,9 +184,11 @@ scratch/main> rewrite woot1to2
184184
-- | Rewrote using:
185185
-- | Modified definition(s): wootEx
186186
187-
ability Woot1 where woot1 : '{Woot1} Nat
187+
ability Woot1 where
188+
woot1 : '{Woot1} Nat
188189
189-
ability Woot2 where woot2 : '{Woot2} Nat
190+
ability Woot2 where
191+
woot2 : '{Woot2} Nat
190192
191193
woot1to2 x =
192194
@rewrite

unison-src/transcripts-round-trip/main.output.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,17 @@ scratch/a1> edit.new 1-1000
4848
```
4949

5050
````` unison :added-by-ucm scratch.u
51-
structural ability Abort where abort : {Abort} a
51+
structural ability Abort where
52+
abort : {Abort} a
5253
53-
structural ability Ask a where ask : {Ask a} a
54+
structural ability Ask a where
55+
ask : {Ask a} a
5456
5557
structural type Fix_2337
5658
= Fix_2337 Boolean Boolean
5759
58-
structural ability Fix_2392 where zonk : {Fix_2392} Nat
60+
structural ability Fix_2392 where
61+
zonk : {Fix_2392} Nat
5962
6063
structural type Fix_2392a x y
6164
= Oog Nat Nat (Nat, Nat)

unison-src/transcripts/idempotent/doc1.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ scratch/main> view lib.builtins.Doc
1515
| Source Link
1616
| Signature Term
1717
| Evaluate Term
18-
| Join [lib.builtins.Doc]
18+
| Join [Doc]
1919
```
2020

2121
You can create these `Doc` values with ordinary code, or you can use the special syntax. A value of structural type `Doc` can be created via syntax like:

unison-src/transcripts/idempotent/formatter.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,8 @@ ability Thing where
138138
139139
140140
Ask.doc = {{ Ability with single constructor }}
141-
structural ability Ask a where ask : {Ask a} a
141+
structural ability Ask a where
142+
ask : {Ask a} a
142143
143144
-- Regression test for: https://github.com/unisonweb/unison/issues/4666
144145
provide : a -> '{Ask a} r -> r

unison-src/transcripts/idempotent/top-level-exceptions.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,9 @@ FYI, here are the `Exception` and `Failure` types:
1010
scratch/main> view Exception Failure
1111
1212
structural ability builtin.Exception where
13-
raise : Failure ->{builtin.Exception} x
13+
raise : Failure ->{Exception} x
1414
15-
type builtin.io2.Failure
16-
= Failure Type Text Any
15+
type builtin.io2.Failure = Failure Type Text Any
1716
```
1817

1918
Here's a sample program just to verify that the typechecker allows `run` to throw exceptions:

0 commit comments

Comments
 (0)