Syntax sugar to test equality #778
ryanprior
started this conversation in
Language Development
Replies: 2 comments
-
Thanks for opening this issue 🙏 I think it is a good opportunity for a helper function: fun mapEq(value : b, function: Function(a, b)) : Function(a, Bool) {
(item : a) { function(item) == value }
}
records
|> Array.select(mapEq(kind, .kind(MyRecord)))
|> Array.map(.kind(MyRecord)) 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
|
Beta Was this translation helpful? Give feedback.
0 replies
-
I moved this to a discussion since there wasn't anything actionable here. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I find myself writing this kind of function a lot:
If we had a syntax sugar such as:
.property=(val, type)
then I could clarify it as such:More general solution: function composition operator?
If we had a function composition operator (suppose we call it
||>
) and a generic equality function (suppose it'sObject.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 anArray(MyRecordType)
. That makes me think it could be possible to propagate that to.kind
, making a hypothetical function real pithy:Beta Was this translation helpful? Give feedback.
All reactions