1
1
mirror of https://github.com/anoma/juvix.git synced 2024-12-15 01:52:11 +03:00
juvix/tests/positive/Judoc.juvix
Jan Mas Rovira 36b390fcb0
Improve formatting of single-constructor types and records (#2342)
- Closes #2331.

The rules implemented in this pr are as follows.
1. If a type definition has only one constructor, no pipe is added. The
constructor is printed in the same line if it fits.
2. If a constructor is a record with a single field, the field is
printed in the same line if it fits. If the constructor has multiple
fields, they are printed aligned and indented after a line break.

Examples:
```
type T := constructT : T;

type T-wrapper := mkWrapper {unwrap : T};

type EnumRecord :=
  | --- doc for C1
    C1 {
      c1a : T;
      c1b : T
    }
  | C2 {
      c2a : T;
      c2b : T
    };
```
2023-09-07 16:20:14 +02:00

45 lines
594 B
Plaintext

module Judoc;
axiom A : Type;
axiom b : Type;
--- document type
type T :=
--- document constructor
t : T;
--- blah ;id A; and ;A A id T A id; this is another ;id
id
id; example
--- hahahah
--- and another one ;T;
id : {A : Type} → A → A
| a := a;
--- hellowww
{-- judoc block --}
{-- judoc
block --}
{-- -- --}
{-- --}
{-- f
z ;Type; --}
id2 : {A : Type} → A → A
| a := a
| a := a;
-- }
--- testing double minus --
--- testing triple --- minus
--- testing closing --}.
---
--- second paragraph
axiom B : {A : Type} → A → A;
{-- Hi
Bye
end --}
axiom M : Type;