carp-lang / carp-lang/Carp

Recursive data types

Open
#623 16 comments 0 reactions 0 assignees View on GitHub
difficult nice-to-have under discussion
Dominant language
Haskell
Stars
6k
Forks
187
Avg merge
8d 22h
Merged PRs (30d)
4

Description

Currently, `deftype` doesn't seem to support recursive data types:

(deftype SExpr (Number [Int]) (List [(Array SExpr)]))

This makes sense, because in general recursive data types could make the C struct "infinitely large"; at least, without putting the recursive values on the heap explicitly.

However, since I don't think one can currently put a value on the heap explicitly in Carp (barring manual use of `malloc`/`free`), and since anyway it seems this fails in the parser already, I don't think it's possible to define an s-expression type like the above in Carp.

Is such a feature planned? Am I misunderstanding something?

Contributor guide

Open the contributing guide

Research direction

The issue names no files or tests; begin by reproducing the `deftype` example and tracing where recursive data types are rejected by the parser. Determine whether recursive values can be represented without infinitely sized C structs, then define the feature's accepted syntax and behavior before implementation.

Written by the indexing model from the issue text.

Assessment

Tech stack
haskell
Domain
compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.