parapluu / encore

The Encore compiler.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

two type-functions to get the inner type

ElieOaks opened this issue · comments

There are two different functions in Types.hs that give the inner type of an instance:

  • getResultType which can be used to get the resulting types of functions, streams and futures. However, this function can also be used on arrays to gain access to the type of the elements it contains. As an array is a data structure, and does not return anything, but rather contains this type, this way of using getResultType breaks the principle of seperation of concerns.

  • getTypeParameter which returns the inner type of the instance of a class, e.g. when instantiating the class LinkedList where int is the inner type:
    var x = new LinkedList[int]

EliasC Suggested that this might be an artefact of Encore getting support for arrays, before getting support for parametric polymorphism.

As an array is not a function, or anything that returns a result, perhaps it should not have a result type, so that getResultType can be used, but rather have an argType or something similar so that getTypeParameter can be used to gain access to the type of it's elements instead.