Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

two type-functions to get the inner type #878

Open
ElieOaks opened this issue Apr 24, 2019 · 0 comments
Open

two type-functions to get the inner type #878

ElieOaks opened this issue Apr 24, 2019 · 0 comments

Comments

@ElieOaks
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant