Add support for lists
Janiczek opened this issue · comments
This means:
- add
List (List Expr)
constructorFrontend.Expr
type... solve any compiler errors that arise as a result (emitExpr
etc) - add tests that show all the various ways lists can be written work. For example:
-
[]
,[ ]
-
[1]
,[ 1 ]
-
[1,2]
,[ 1, 2 ]
- I can't think of any more. Let's not deal with newlines right now as that will be more tricky and done in another issue.
-
- partially implement type inference - focus on the items: all items inside list have to have the same type. Should be enough to eg. for list
[A,B,C]
doequals typeA typeB, equals typeA typeC
. Don't have to do all the combinations. This will leave us to do the type of the actual list itself in a later issue after we implement type parameters. - add emit tests too:
- Elm's
[ 1, 2, 3 ]
➡️ JavaScript's[1, 2, 3]
-
[]
➡️[]
- Elm's
- implement emitting to pass the emit tests above
- update the "what's done" table in README for lists: parser tests, desugaring (none), type inference (only partially =
⚠️ ), emit and emit tests... but not parsers and optimizations.
If you get stuck on anything, ask here or on Discord! We'll help you 🙂
Out of scope ❌ ❌ ❌
- tests for newlines support in lists
- parser for lists
- optimizations (they'll become available with the operators but not sooner I think ... at least I can't think of any)
- type inference of list itself
-
(::)
operator -
(++)
operator