I find myself writing this kind of function a lot:
let kind = "target kind"
records |> Array.select((record : MyRecordType) { record.kind == kind })
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:
records |> Array.select(.kind(MyRecordType) ||> Object.eq(kind))
...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:
records |> Array.select(.kind=(kind))
// or...
records |> Array.select(.kind ||> Object.eq(kind))
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
recordsat 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: