Skip to content

two type-functions to get the inner type #878

@ElieOaks

Description

@ElieOaks

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions