Skip to content
This repository was archived by the owner on Jun 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 17 additions & 24 deletions src/res_outcome_printer.ml
Original file line number Diff line number Diff line change
Expand Up @@ -435,8 +435,8 @@ let printPolyVarIdent txt =
)
]
);
Doc.softLine;
Doc.trailingComma;
Doc.softLine;
Doc.rbrace;
]
)
Expand Down Expand Up @@ -678,29 +678,22 @@ let printPolyVarIdent txt =
let constraints = match outTypeDecl.otype_cstrs with
| [] -> Doc.nil
| _ -> Doc.group (
Doc.concat [
Doc.line;
Doc.indent (
Doc.concat [
Doc.hardLine;
Doc.join ~sep:Doc.line (List.map (fun (typ1, typ2) ->
Doc.group (
Doc.concat [
Doc.text "constraint ";
printOutTypeDoc typ1;
Doc.text " =";
Doc.indent (
Doc.concat [
Doc.line;
printOutTypeDoc typ2;
]
)
]
)
) outTypeDecl.otype_cstrs)
]
)
]
Doc.indent (
Doc.concat [
Doc.hardLine;
Doc.join ~sep:Doc.line (List.map (fun (typ1, typ2) ->
Doc.group (
Doc.concat [
Doc.text "constraint ";
printOutTypeDoc typ1;
Doc.text " =";
Doc.space;
printOutTypeDoc typ2;
]
)
) outTypeDecl.otype_cstrs)
]
)
) in
Doc.group (
Doc.concat [
Expand Down
15 changes: 15 additions & 0 deletions tests/oprint/oprint.res
Original file line number Diff line number Diff line change
Expand Up @@ -264,3 +264,18 @@ type obj6 = {"a": int}
type obj7 = {. "a": int}
type obj8<'a> = {.. "a": int} as 'a

type objUser = {"name": string, "age": int}
type objUserWithLongFields = {"name": string, "x": int, "age": int, "looooooongFiiiiiiiieeeeeeeldName": string, "anoooooooooooooooootherLongFiiiiiieeeeeeeldName": int}

type objectCoordinate = {"x": float, "y": float}
type threeDimensionalCoordinate = {...objectCoordinate, "z": float}
type differentSpreadedCoordinate = {"z": float, ...objectCoordinate, "alpha": int}

type multiSpreadedCoordinate = {
...threeDimensionalCoordinate,
"a": int,
...differentSpreadedCoordinate,
"b": int
}

type dotdotObjectCoordinate<'a> = {.. "suuuuuuuuuuuperLooooooooooooongFieldNaaaaaaaaaaaame": float, "suuuuuuuuuuuperLooooooooooooongFieldNaaaaaaaaaaaame2222222222222": float} as 'a
33 changes: 30 additions & 3 deletions tests/oprint/oprint.res.snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -404,10 +404,37 @@ type obj2 = {"a": int}
type obj3 = {"a": int}
type obj4 = {"a": int}
type obj5<'a> = Js.t<'a>

constraint 'a = {..}
type obj6 = {"a": int}
type obj7 = {"a": int}
type obj8<'a> = 'a

constraint 'a = {.."a": int}
constraint 'a = {.."a": int}
type objUser = {"age": int, "name": string}
type objUserWithLongFields = {
"age": int,
"anoooooooooooooooootherLongFiiiiiieeeeeeeldName": int,
"looooooongFiiiiiiiieeeeeeeldName": string,
"name": string,
"x": int,
}
type objectCoordinate = {"x": float, "y": float}
type threeDimensionalCoordinate = {"x": float, "y": float, "z": float}
type differentSpreadedCoordinate = {
"alpha": int,
"x": float,
"y": float,
"z": float,
}
type multiSpreadedCoordinate = {
"a": int,
"alpha": int,
"b": int,
"x": float,
"y": float,
"z": float,
}
type dotdotObjectCoordinate<'a> = 'a
constraint 'a = {..
"suuuuuuuuuuuperLooooooooooooongFieldNaaaaaaaaaaaame": float,
"suuuuuuuuuuuperLooooooooooooongFieldNaaaaaaaaaaaame2222222222222": float,
}