Type an array #60
-
|
Hi! First of all, thank you very much for this nice library, my type validation rules in Langium were starting to get a bit messy and I think I can replace some of them thanks to this library. :D And I want to:
I don't know if the two last rules are in the scope of a type system, but concerning the first, I would like a generic method to not have to declare a rule for each of my types.
So the two lasts are types defined by the user. This question may be linked to #34. Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
|
Hello @theogiraudet, thanks for your interest in Typir!
Officially not yet, but we are working on types we are calling
Yes, type inference will be supported for this case
The number of elements inside an array variable at runtime is not part of a type system. But "restricting" an unlimited array (or list) with a size (or upper limit, which is constant and independent from the actual number of elements in the array at runtime) is another, cross-cutting feature. It is not under develop right at the moment, but on our roadmap: #38 describes it for primitive types, but such restrictions will very likely be supported for any types.
No, such a check is not part of Typir, since it is not enough, that the elements have the wanted type (that is a type-related validation yes), but all their values/properties need to be the same (which is a "usual" validation beyond type checking).
Yes, they are already supported by Typir
We support nominally typed classes at the moment. Maybe you can reuse them for your DSL and just don't specify any methods.
They are on our roadmap, I just created #61 to make that explicit 🙂
That is supported by Typir and demonstrated in this example with user-defined functions and classes. Additionally, this example has some fixed primitives.
That depends on your DSL, in particular its operators (and predefined functions?). In the examples you showed above, I saw no "dynamically computed types".
We looking forward to hear about your experience and get some feedback to improve Typir! |
Beta Was this translation helpful? Give feedback.
Hello @theogiraudet,
thanks for your interest in Typir!
Officially not yet, but we are working on types we are calling
FixedParameterTypeat the moment. They are designed to represent types likeSet<A>,Collection<B>orMap<K, V>, or in your caseArray<Integer>. First implementations are already onmainand here is a sketch how to use them. But there are no test cases for them, support for cyclic type definitions is missing and so on. We plan to support this feature for v0.2 (#44)Yes, type inference will be supported for this case