Commit 05c8fdd
committed
Change Show-instances to use
The previous show instance would add another layer of quoting for each
nesting:
```
ghci> show (rcons (#foo := "bar") rnil)
"[(\"foo\",\"\\\"bar\\\"\")]"
```
Instead, what we want is to display a nicely readable variant of the
record, using the infix field syntax for both label/value pairs and
full records:
```
ghci> show (rcons (#hi := (rcons (#lea := "hi") rnil)) (rcons (#foo := "bar") rnil ))
"[#foo := \"bar\",#hi := [(#lea := \"hi\")]]"
ghci> show (#hi := "lea")
"#hi := \"lea\""
```
That’s better!
Note that we can’t have a roundtripping `Read` instance anyway, so we
might as well have `Show` be readable.
Fixes #36"#field := val"
1 parent 5a7d686 commit 05c8fdd
3 files changed
Lines changed: 16 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
101 | 101 | | |
102 | 102 | | |
103 | 103 | | |
| 104 | + | |
104 | 105 | | |
105 | 106 | | |
106 | 107 | | |
| |||
160 | 161 | | |
161 | 162 | | |
162 | 163 | | |
163 | | - | |
| 164 | + | |
164 | 165 | | |
165 | 166 | | |
166 | 167 | | |
| |||
712 | 713 | | |
713 | 714 | | |
714 | 715 | | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
715 | 723 | | |
716 | 724 | | |
717 | 725 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
32 | | - | |
33 | | - | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
34 | 38 | | |
35 | 39 | | |
36 | 40 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
351 | 351 | | |
352 | 352 | | |
353 | 353 | | |
354 | | - | |
| 354 | + | |
355 | 355 | | |
356 | 356 | | |
357 | 357 | | |
| |||
0 commit comments