It should not be possible to create infinite datatypes #48

Open
opened 2023-06-02 20:41:50 +02:00 by samvv · 0 comments
samvv commented 2023-06-02 20:41:50 +02:00 (Migrated from github.com)

Problem

Consider the following definition:

enum List a.
  Nil
  Pair a (List a)

Here, the recursive call to List a is wrapped in a Pair, which makes everything OK.

Imagine now the following type:

enum Node a.
  Ref (Node a)

Here, the datatype is clearly invalid because to instantiate it you would need an infinite sequence of Refs.

The compiler needs a check to prevent this from happening.

## Problem Consider the following definition: ``` enum List a. Nil Pair a (List a) ``` Here, the recursive call to `List a` is wrapped in a `Pair`, which makes everything OK. Imagine now the following type: ``` enum Node a. Ref (Node a) ``` Here, the datatype is clearly invalid because to instantiate it you would need an infinite sequence of `Ref`s. The compiler needs a check to prevent this from happening.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: samvv/bolt#48
No description provided.