CakeML / CakeML/cakeml

astPP doesn't print algebraic datatype correctly

Open
#480 7 comments 0 reactions 0 assignees View on GitHub
dev experience help wanted low reward
Dominant language
Standard ML
Stars
1.2k
Forks
104
Avg merge
2d 21h
Merged PRs (30d)
16

Description

Hi,

With the following datatype:

```ml
datatype 'a misc_app_list =
Nil
| Append of 'a misc_app_list * 'a misc_app_list
| List of 'a list;
```

Here's an example of what is produced:

```ml
(Append(Append(v2,List([", "])),v5 v1))
```

I.e:

```ml
(Append
(Append
(v2,
List([", "])
),
v5 v1
)
)
```

When it should be:

```ml
(Append
(Append
(v2)
( List([", "]) )
)
( v5 v1 )
)
```

Shortly, `Append x y` is printed as `Append (x, y)` instead of `Append (x) (y)`.
My guess is that it's printed by the same function than the one used to print `lists` or things like:

```ml
case v3 of
(v2,v1) => (* <- this *)
```

To fix this, it should not print a `, ` but `) (` between things.

It's working for the constructor `List`, but I think it's because it takes only one argument, so the bug doesn't show.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.