diff --git a/hugr-core/src/hugr/views/snapshots/hugr_core__hugr__views__tests__dot_cfg.snap b/hugr-core/src/hugr/views/snapshots/hugr_core__hugr__views__tests__dot_cfg.snap
index 7f7d769be..a54bd96e6 100644
--- a/hugr-core/src/hugr/views/snapshots/hugr_core__hugr__views__tests__dot_cfg.snap
+++ b/hugr-core/src/hugr/views/snapshots/hugr_core__hugr__views__tests__dot_cfg.snap
@@ -17,10 +17,10 @@ digraph {
6:out0 -> 1:in0 [style="dashed"]
7 [shape=plain label=<
>]
7:out0 -> 8:in1 [style=""]
-8 [shape=plain label=<>]
-9 [shape=plain label=<>]
+8 [shape=plain label=<0: Unit | 1: usize |
(8) Output |
>]
+9 [shape=plain label=<>]
9:out0 -> 10:in0 [style=""]
-10 [shape=plain label=<0: [] |
(10) LoadConstant |
0: [] |
>]
+10 [shape=plain label=<0: Unit |
(10) LoadConstant |
0: Unit |
>]
10:out0 -> 8:in0 [style=""]
hier0 [shape=plain label="0"]
hier0 -> hier2 [style = "dashed"]
diff --git a/hugr-core/src/hugr/views/snapshots/hugr_core__hugr__views__tests__dot_empty_dfg.snap b/hugr-core/src/hugr/views/snapshots/hugr_core__hugr__views__tests__dot_empty_dfg.snap
index 0bae7e511..b9e4e8e9f 100644
--- a/hugr-core/src/hugr/views/snapshots/hugr_core__hugr__views__tests__dot_empty_dfg.snap
+++ b/hugr-core/src/hugr/views/snapshots/hugr_core__hugr__views__tests__dot_empty_dfg.snap
@@ -3,10 +3,10 @@ source: hugr-core/src/hugr/views/tests.rs
expression: h.dot_string()
---
digraph {
-0 [shape=plain label=<>]
-1 [shape=plain label=<>]
+0 [shape=plain label=<>]
+1 [shape=plain label=<>]
1:out0 -> 2:in0 [style=""]
-2 [shape=plain label=<>]
+2 [shape=plain label=<>]
hier0 [shape=plain label="0"]
hier0 -> hier1 [style = "dashed"]
hier0 -> hier2 [style = "dashed"]
diff --git a/hugr-core/src/hugr/views/snapshots/hugr_core__hugr__views__tests__dot_func.snap b/hugr-core/src/hugr/views/snapshots/hugr_core__hugr__views__tests__dot_func.snap
index e1bbeae4e..7583256d4 100644
--- a/hugr-core/src/hugr/views/snapshots/hugr_core__hugr__views__tests__dot_func.snap
+++ b/hugr-core/src/hugr/views/snapshots/hugr_core__hugr__views__tests__dot_func.snap
@@ -3,10 +3,10 @@ source: hugr-core/src/hugr/views/tests.rs
expression: h.dot_string()
---
digraph {
-0 [shape=plain label=<(0) FuncDefn: "test" |
0: [[]+[]] -> [[]][[]+[]] |
>]
-1 [shape=plain label=<>]
+0 [shape=plain label=<(0) FuncDefn: "test" |
0: [Bool] -> [[]][Bool] |
>]
+1 [shape=plain label=<>]
1:out0 -> 2:in0 [style=""]
-2 [shape=plain label=<>]
+2 [shape=plain label=<>]
hier0 [shape=plain label="0"]
hier0 -> hier1 [style = "dashed"]
hier0 -> hier2 [style = "dashed"]
diff --git a/hugr-core/src/hugr/views/snapshots/hugr_core__hugr__views__tests__dot_module.snap b/hugr-core/src/hugr/views/snapshots/hugr_core__hugr__views__tests__dot_module.snap
index 37691fa9c..57cb0c9da 100644
--- a/hugr-core/src/hugr/views/snapshots/hugr_core__hugr__views__tests__dot_module.snap
+++ b/hugr-core/src/hugr/views/snapshots/hugr_core__hugr__views__tests__dot_module.snap
@@ -4,7 +4,7 @@ expression: h.dot_string()
---
digraph {
0 [shape=plain label=<>]
-1 [shape=plain label=<(1) FuncDecl: "test" |
0: [[]+[]] -> [[]][[]+[]] |
>]
+1 [shape=plain label=<(1) FuncDecl: "test" |
0: [Bool] -> [[]][Bool] |
>]
hier0 [shape=plain label="0"]
hier0 -> hier1 [style = "dashed"]
hier1 [shape=plain label="1"]
diff --git a/hugr-core/src/hugr/views/snapshots/hugr_core__hugr__views__tests__mmd_cfg.snap b/hugr-core/src/hugr/views/snapshots/hugr_core__hugr__views__tests__mmd_cfg.snap
index 33f9fad3e..9bbdb0f2d 100644
--- a/hugr-core/src/hugr/views/snapshots/hugr_core__hugr__views__tests__mmd_cfg.snap
+++ b/hugr-core/src/hugr/views/snapshots/hugr_core__hugr__views__tests__mmd_cfg.snap
@@ -21,8 +21,8 @@ graph LR
9["(9) const:seq:{}"]
10["(10) LoadConstant"]
7--"0:1
usize"-->8
- 9--"0:0
[]"-->10
- 10--"0:0
[]"-->8
+ 9--"0:0
Unit"-->10
+ 10--"0:0
Unit"-->8
end
2-."0:0".->6
2-."1:0".->1
diff --git a/hugr-core/src/hugr/views/snapshots/hugr_core__hugr__views__tests__mmd_empty_dfg.snap b/hugr-core/src/hugr/views/snapshots/hugr_core__hugr__views__tests__mmd_empty_dfg.snap
index 52e8ce4e7..85e2a8284 100644
--- a/hugr-core/src/hugr/views/snapshots/hugr_core__hugr__views__tests__mmd_empty_dfg.snap
+++ b/hugr-core/src/hugr/views/snapshots/hugr_core__hugr__views__tests__mmd_empty_dfg.snap
@@ -7,5 +7,5 @@ graph LR
direction LR
1["(1) Input"]
2["(2) Output"]
- 1--"0:0
[]+[]"-->2
+ 1--"0:0
Bool"-->2
end
diff --git a/hugr-core/src/hugr/views/snapshots/hugr_core__hugr__views__tests__mmd_func.snap b/hugr-core/src/hugr/views/snapshots/hugr_core__hugr__views__tests__mmd_func.snap
index 45bf1a427..edfdb0534 100644
--- a/hugr-core/src/hugr/views/snapshots/hugr_core__hugr__views__tests__mmd_func.snap
+++ b/hugr-core/src/hugr/views/snapshots/hugr_core__hugr__views__tests__mmd_func.snap
@@ -7,5 +7,5 @@ graph LR
direction LR
1["(1) Input"]
2["(2) Output"]
- 1--"0:0
[]+[]"-->2
+ 1--"0:0
Bool"-->2
end
diff --git a/hugr-core/src/snapshots/hugr_core__package__test__cfg.snap b/hugr-core/src/snapshots/hugr_core__package__test__cfg.snap
index 3262c52fc..47a48e5af 100644
--- a/hugr-core/src/snapshots/hugr_core__package__test__cfg.snap
+++ b/hugr-core/src/snapshots/hugr_core__package__test__cfg.snap
@@ -27,8 +27,8 @@ graph LR
14["(14) const:seq:{}"]
15["(15) LoadConstant"]
12--"0:1
usize"-->13
- 14--"0:0
[]"-->15
- 15--"0:0
[]"-->13
+ 14--"0:0
Unit"-->15
+ 15--"0:0
Unit"-->13
end
6-."0:0".->10
6-."1:0".->5
diff --git a/hugr-core/src/snapshots/hugr_core__package__test__dfg.snap b/hugr-core/src/snapshots/hugr_core__package__test__dfg.snap
index fd1a0c0ef..24f534985 100644
--- a/hugr-core/src/snapshots/hugr_core__package__test__dfg.snap
+++ b/hugr-core/src/snapshots/hugr_core__package__test__dfg.snap
@@ -9,6 +9,6 @@ graph LR
direction LR
1["(1) Input"]
2["(2) Output"]
- 1--"0:0
[]+[]"-->2
+ 1--"0:0
Bool"-->2
end
end
diff --git a/hugr-core/src/snapshots/hugr_core__package__test__funcdef.snap b/hugr-core/src/snapshots/hugr_core__package__test__funcdef.snap
index edeb76dbb..27a2eeb53 100644
--- a/hugr-core/src/snapshots/hugr_core__package__test__funcdef.snap
+++ b/hugr-core/src/snapshots/hugr_core__package__test__funcdef.snap
@@ -9,6 +9,6 @@ graph LR
direction LR
1["(1) Input"]
2["(2) Output"]
- 1--"0:0
[]+[]"-->2
+ 1--"0:0
Bool"-->2
end
end
diff --git a/hugr-core/src/types.rs b/hugr-core/src/types.rs
index 655531ab5..24a6f43cd 100644
--- a/hugr-core/src/types.rs
+++ b/hugr-core/src/types.rs
@@ -148,10 +148,16 @@ impl std::fmt::Display for SumType {
}
match self {
+ SumType::Unit { size: 1 } => write!(f, "Unit"),
+ SumType::Unit { size: 2 } => write!(f, "Bool"),
SumType::Unit { size } => {
display_list_with_separator(repeat_n("[]", *size as usize), f, "+")
}
- SumType::General { rows } => display_list_with_separator(rows.iter(), f, "+"),
+ SumType::General { rows } => match rows.len() {
+ 1 if rows[0].is_empty() => write!(f, "Unit"),
+ 2 if rows[0].is_empty() && rows[1].is_empty() => write!(f, "Bool"),
+ _ => display_list_with_separator(rows.iter(), f, "+"),
+ },
}
}
}