Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a basic implementation of lists for Numbat. We construct lists using
[…]
notation and the type of lists is specified asList<T>
whereT
can be any type.Operationally, they work just fine. For example, we can add the functional-programming style primitives
head
,tail
andcons
:and they work as expected:
We can even write some useful functions like
Type checking of list construction also works fine:
However, there are a number of open questions / issues regarding the handling of lists in the type checker:
[]
, which should have the type∀D. List<D>
. We have a similar problem with typing0
,NaN
andinf
, see Zero, NaN, inf should be polymorphic #37.map
,filter
, etc., we are running into type inference problems (already reported as Can not infer type parameter when calling generic function from generic function #166).Scalar
,Length
,Length^2
,Length / Time
, etc). But so far, we can't be generic over all types, which means we can not give a type to a function that works on all lists, only on lists of arbitrary dimension types. So we can create things likeList<Bool>
,List<String>
orList<List<Length>>
, but we can't runcons
,head
,tail
on them.related ticket: #261