-
I was wondering how could I
or
or
In all these cases, when I run
The only thing I got to work was something like:
which is useful, but not as useful as if I could just alias Is there a way to extend these base types? Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
You've brushed up against an important core language feature of Pkl: types and methods have different namespaces. Methods can exist with the same name as types within the same module and In this case, you should be able to define a function KV(key: String, value: Int): KV = Pair<String, Int>(key, value) You can see that similar is done for Line 1966 in 7da643f |
Beta Was this translation helpful? Give feedback.
-
However, if I wanted to not just
And I get the following error:
That's surprising! because it clearly says Lines 1971 to 1983 in 7da643f Any ideas on this one? 🙏 and/or #478 which is the same/related but even a bit more complex. Thanks!! |
Beta Was this translation helpful? Give feedback.
You've brushed up against an important core language feature of Pkl: types and methods have different namespaces. Methods can exist with the same name as types within the same module and
pkl:base
'sPair
,List
, andMap
are a few examples of this.In this case, you should be able to define a
KV
"constructor" method in your module to achieve what you're looking for:You can see that similar is done for
Pair
here:pkl/stdlib/base.pkl
Line 1966 in 7da643f