What would be the best way to extend the Kind factory in Typir Langium? #77
Replies: 2 comments
-
Hello @CarlosGamez-Nova, your implementation looks already very nice and is on track! Yes, using We are currently working on several improvements to support custom types like your ones and hope to release them as v0.3 end of June. Waiting for that might save some implementation effort on your side 🙂 Since implementing kinds/factories for custom types on your own is not simple at the moment, we want to support an easier API for custom types in Typir. We are currently discussing #73 for that. Inspired by your question, I created #78 to make additional factory services like Another idea which came to my mind: Would it be possible to describe your dimensions with the predefined (nominally typed) classes factory? The units become class fields and the conversions become class methods. |
Beta Was this translation helpful? Give feedback.
-
Hi @JohannesMeierSE, Thank you for your reply and advice. This library is a great way to build a statically typed language. I think the factory services you are implementing are exactly what I would need to implement Furthermore, if there's anything I can do to help with these new features, please do not hesitate to ask. I've been thinking about creating a guide for a newcomer that is currently using Langium on how to integrate Typir into the mix (which is what I've been doing over the past few months). Your last idea is spot on. In fact, I have a rough implementation of Dimensions using fields for Units and functions for Conversions. It did work. I just noticed things like the naming convention 'class-', which in my case I'd like to override to something like 'dimension-'. Ultimately I decided it would be more "correct" for me to try to properly implement these new types in the factory, which led me to the path I'm currently on. I ended up extending a few of the native Typir constructs to make that work. I'm guessing with the implementation of the new API, some of these things won't be necessary. You are correct, |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
In my language I have two types that I would like to build factories for.
I'm trying to create a language where units of measure is a native type construct in the language. Units of measure are declared in a Dimension, which can have several units defined and conversion functions. See the example below:
I am trying to create a factory and related services to manage the registration of Dimensions and Units.
So far I have tried extending the module definition of my language and use the
customization1
property, but I'm not sure that's where I should be doing this.Any pointers to the right approach would be highly appreciated.
If it helps, this is where this project lives with a branch dedicated to implement types using typir:
https://github.com/EngineersTools/e-lang/tree/feat/implement-typir
Beta Was this translation helpful? Give feedback.
All reactions