You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If we had a syntax sugar such as: .property=(val, type) then I could clarify it as such:
records|>Array.select(.kind=(kind, MyRecordType))
More general solution: function composition operator?
If we had a function composition operator (suppose we call it ||>) and a generic equality function (suppose it's Object.eq) then I could rewrite the function as:
...which is almost as nice as the syntax sugar, and much more general.
While I'm making wishes
Mint knows the type of records at compile-time: it's an Array(MyRecordType). That makes me think it could be possible to propagate that to .kind, making a hypothetical function real pithy:
Syntax sugar: Personally, I don't want to introduce more syntax sugars. I had/have a hard time understanding Haskell, and I'm afraid if we add more Mint will be hard to understand as well.
The type of field access (.kind) were optional before and basically was a syntax sugar for (item: {kind: a, ...}) { item.kind } and caused some type checking bugs. Maybe there is a way to make sure that we can resolve the type properly, I'll put in on the wishlist 🙂
Activity
gdotdesign commentedon Mar 31, 2025
Thanks for opening this issue 🙏
I think it is a good opportunity for a helper function:
There could be a package with a module with a bunch of these helper functions.
A working example here: https://mint-lang.com/sandbox/UPQfBJi5vWzNVA
.kind) were optional before and basically was a syntax sugar for(item: {kind: a, ...}) { item.kind }and caused some type checking bugs. Maybe there is a way to make sure that we can resolve the type properly, I'll put in on the wishlist 🙂